Fixed crash blitting to an 8-bit surface with no palette
This commit is contained in:
@@ -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 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixelvalue, const SDL_Palette *pal)
|
||||||
{
|
{
|
||||||
Uint8 color_index = 0;
|
Uint8 color_index = 0;
|
||||||
|
if (pal) {
|
||||||
const void *value;
|
const void *value;
|
||||||
if (SDL_FindInHashTable(palette_map, (const void *)(uintptr_t)pixelvalue, &value)) {
|
if (SDL_FindInHashTable(palette_map, (const void *)(uintptr_t)pixelvalue, &value)) {
|
||||||
color_index = (Uint8)(uintptr_t)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);
|
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);
|
SDL_InsertIntoHashTable(palette_map, (const void *)(uintptr_t)pixelvalue, (const void *)(uintptr_t)color_index, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return color_index;
|
return color_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user