diff -r 587922004ea0 -r 07c39cbbeacf src/video/SDL_bmp.c --- a/src/video/SDL_bmp.c Sun Feb 17 16:20:23 2019 +0100 +++ b/src/video/SDL_bmp.c Mon Feb 18 07:50:33 2019 -0800 @@ -313,6 +313,10 @@ SDL_assert(biBitCount <= 8); if (biClrUsed == 0) { biClrUsed = 1 << biBitCount; + } else if (biClrUsed > (1 << biBitCount)) { + SDL_SetError("BMP file has an invalid number of colors"); + was_error = SDL_TRUE; + goto done; } if ((int) biClrUsed > palette->ncolors) { SDL_Color *colors;