Fixed bug 4538 - validate image size when loading BMP files SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Tue, 30 Jul 2019 21:29:15 +0300
branchSDL-1.2
changeset 685a59bfe382008
parent 681 9ccaa3a0dfb6
child 689 18420656c373
Fixed bug 4538 - validate image size when loading BMP files
IMG_bmp.c
     1.1 --- a/IMG_bmp.c	Thu Jul 11 01:01:56 2019 +0300
     1.2 +++ b/IMG_bmp.c	Tue Jul 30 21:29:15 2019 +0300
     1.3 @@ -272,6 +272,11 @@
     1.4  		biClrUsed	= SDL_ReadLE32(src);
     1.5  		biClrImportant	= SDL_ReadLE32(src);
     1.6  	}
     1.7 +	if (biWidth <= 0 || biHeight == 0) {
     1.8 +		IMG_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight);
     1.9 +		was_error = SDL_TRUE;
    1.10 +		goto done;
    1.11 +	}
    1.12  	if (biHeight < 0) {
    1.13  		topDown = SDL_TRUE;
    1.14  		biHeight = -biHeight;