Browse Source

Fail blits between indexed and RGB surfaces if there is no palette set

Sam Lantinga 9 months ago
parent
commit
626bb53772
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/video/SDL_pixels.c

+ 6 - 6
src/video/SDL_pixels.c

@@ -1379,17 +1379,17 @@ static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod
     int i;
     int bpp;
 
+    if (!pal) {
+        SDL_SetError("src does not have a palette set");
+        return NULL;
+    }
+
     bpp = ((SDL_BYTESPERPIXEL(dst->format) == 3) ? 4 : SDL_BYTESPERPIXEL(dst->format));
     map = (Uint8 *)SDL_calloc(256, bpp);
     if (!map) {
         return NULL;
     }
 
-    /* An all-zero map for surfaces without a palette. */
-    if (!pal) {
-        return map;
-    }
-
     /* We memory copy to the pixel map so the endianness is preserved */
     for (i = 0; i < pal->ncolors; ++i) {
         Uint8 R = (Uint8)((pal->colors[i].r * Rmod) / 255);
@@ -1410,7 +1410,7 @@ static Uint8 *MapNto1(const SDL_PixelFormatDetails *src, const SDL_Palette *pal,
     SDL_Color colors[256];
 
     if (!pal) {
-        *identical = 1;
+        SDL_SetError("dst does not have a palette set");
         return NULL;
     }