Fixed crash blitting to an 8-bit surface with no palette

This commit is contained in:
Sam Lantinga
2025-11-10 13:03:00 -08:00
parent 6389f4db4c
commit ff890d1733

View File

@@ -1217,6 +1217,7 @@ static Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Ui
Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixelvalue, const SDL_Palette *pal)
{
Uint8 color_index = 0;
if (pal) {
const void *value;
if (SDL_FindInHashTable(palette_map, (const void *)(uintptr_t)pixelvalue, &value)) {
color_index = (Uint8)(uintptr_t)value;
@@ -1228,6 +1229,7 @@ Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixelvalue, const S
color_index = SDL_FindColor(pal, r, g, b, a);
SDL_InsertIntoHashTable(palette_map, (const void *)(uintptr_t)pixelvalue, (const void *)(uintptr_t)color_index, true);
}
}
return color_index;
}