Fix SSMS issue 52/299752/2
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 10 Oct 2023 01:37:20 +0000 (10:37 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Tue, 10 Oct 2023 02:03:27 +0000 (11:03 +0900)
Always create a full 256-entry map in case color values are out of range
https://github.com/libsdl-org/SDL/commit/8c91cf7dba5193f5ce12d06db1336515851c9ee9

Change-Id: I4aa9582fe207788a329778952c13414c7da88f92
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/video/SDL_pixels.c

index 84b6932..1fd3b19 100644 (file)
@@ -29,6 +29,7 @@
 #include "SDL_pixels_c.h"
 #include "SDL_RLEaccel_c.h"
 
+#define SDL_CallocNumber 256
 
 /* Lookup tables to expand partial bytes to the full 0..255 range */
 
@@ -947,7 +948,7 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
         }
         *identical = 0;
     }
-    map = (Uint8 *) SDL_malloc(src->ncolors);
+    map = (Uint8 *) SDL_calloc(SDL_CallocNumber, sizeof(Uint8));
     if (map == NULL) {
         SDL_OutOfMemory();
         return (NULL);
@@ -971,7 +972,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
     SDL_Palette *pal = src->palette;
 
     bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
-    map = (Uint8 *) SDL_malloc(pal->ncolors * bpp);
+    map = (Uint8 *) SDL_calloc(SDL_CallocNumber, bpp);
     if (map == NULL) {
         SDL_OutOfMemory();
         return (NULL);