瀏覽代碼

Don't use SDL_SIMDFree() if the pixels haven't been allocated with SDL_SIMDAlloc()

Sam Lantinga 3 年之前
父節點
當前提交
6da99d4a6c
共有 1 個文件被更改,包括 12 次插入4 次删除
  1. 12 4
      src/video/SDL_RLEaccel.c

+ 12 - 4
src/video/SDL_RLEaccel.c

@@ -1218,9 +1218,13 @@ RLEAlphaSurface(SDL_Surface * surface)
 
 
     /* Now that we have it encoded, release the original pixels */
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
     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->pixels = NULL;
-        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
     }
 
 
     /* reallocate the buffer to release unused memory */
     /* reallocate the buffer to release unused memory */
@@ -1382,9 +1386,13 @@ RLEColorkeySurface(SDL_Surface * surface)
 
 
     /* Now that we have it encoded, release the original pixels */
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
     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->pixels = NULL;
-        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
     }
 
 
     /* reallocate the buffer to release unused memory */
     /* reallocate the buffer to release unused memory */