mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-23 21:55:12 +00:00
Always create a full 256-entry map in case color values are out of range
Fixes https://github.com/libsdl-org/SDL/issues/5042
This commit is contained in:
parent
056c09942d
commit
8c91cf7dba
|
@ -947,7 +947,7 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
|
||||||
}
|
}
|
||||||
*identical = 0;
|
*identical = 0;
|
||||||
}
|
}
|
||||||
map = (Uint8 *) SDL_malloc(src->ncolors);
|
map = (Uint8 *) SDL_calloc(256, sizeof(Uint8));
|
||||||
if (map == NULL) {
|
if (map == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -971,7 +971,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
|
||||||
SDL_Palette *pal = src->palette;
|
SDL_Palette *pal = src->palette;
|
||||||
|
|
||||||
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
|
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
|
||||||
map = (Uint8 *) SDL_malloc(pal->ncolors * bpp);
|
map = (Uint8 *) SDL_calloc(256, bpp);
|
||||||
if (map == NULL) {
|
if (map == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
Loading…
Reference in a new issue