diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 67445c771..ecf31aff4 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -407,14 +407,20 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) goto done; } - /* - | guich: always use 1< palette->ncolors) { + biClrUsed = 1 << biBitCount; /* try forcing it? */ + if (biClrUsed > palette->ncolors) { + SDL_SetError("Unsupported or incorrect biClrUsed field"); + was_error = SDL_TRUE; + goto done; + } + } + + if (biSize == 12) { for (i = 0; i < (int) biClrUsed; ++i) { SDL_RWread(src, &palette->colors[i].b, 1, 1); SDL_RWread(src, &palette->colors[i].g, 1, 1);