SDL: Don't use SDL_SIMDFree() if the pixels haven't been allocated with SDL_SIMDAlloc() (1ce75)

From 1ce752ae97736a268be4743f7c71243bb09b8e54 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 11 May 2022 08:40:17 -0700
Subject: [PATCH] Don't use SDL_SIMDFree() if the pixels haven't been allocated
 with SDL_SIMDAlloc()

---
 src/video/SDL_RLEaccel.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c
index 983c9d91422..b928fd7d7cd 100644
--- a/src/video/SDL_RLEaccel.c
+++ b/src/video/SDL_RLEaccel.c
@@ -1222,9 +1222,13 @@ RLEAlphaSurface(SDL_Surface * surface)
 
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
-        SDL_SIMDFree(surface->pixels);
+        if (surface->flags & SDL_SIMD_ALIGNED) {
+            SDL_SIMDFree(surface->pixels);
+            surface->flags &= ~SDL_SIMD_ALIGNED;
+        } else {
+            SDL_free(surface->pixels);
+        }
         surface->pixels = NULL;
-        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
 
     /* reallocate the buffer to release unused memory */
@@ -1386,9 +1390,13 @@ RLEColorkeySurface(SDL_Surface * surface)
 
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
-        SDL_SIMDFree(surface->pixels);
+        if (surface->flags & SDL_SIMD_ALIGNED) {
+            SDL_SIMDFree(surface->pixels);
+            surface->flags &= ~SDL_SIMD_ALIGNED;
+        } else {
+            SDL_free(surface->pixels);
+        }
         surface->pixels = NULL;
-        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
 
     /* reallocate the buffer to release unused memory */