From e12c931e5bb260821ac7f11833eb627331779dcf Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 30 Jul 2019 21:29:15 +0300 Subject: [PATCH] Fixed bug 4538 - validate image size when loading BMP files --- IMG_bmp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/IMG_bmp.c b/IMG_bmp.c index bb2517b8..9e3ab889 100644 --- a/IMG_bmp.c +++ b/IMG_bmp.c @@ -272,6 +272,11 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc) biClrUsed = SDL_ReadLE32(src); biClrImportant = SDL_ReadLE32(src); } + if (biWidth <= 0 || biHeight == 0) { + IMG_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight); + was_error = SDL_TRUE; + goto done; + } if (biHeight < 0) { topDown = SDL_TRUE; biHeight = -biHeight;