From 626bb5377261e8481286cf055af33fe668753bac Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 16 Jul 2024 11:58:31 -0700 Subject: [PATCH] Fail blits between indexed and RGB surfaces if there is no palette set --- src/video/SDL_pixels.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 6f00f2aae4..e265f8473c 100644 --- a/src/video/SDL_pixels.c +++ b/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; }