Fixed bug 4538 - validate image size when loading BMP files
authorSam Lantinga <slouken@libsdl.org>
Tue, 30 Jul 2019 11:00:12 -0700
changeset 684ba45f00879ba
parent 683 f1baffa48926
child 686 4ac6bc242c62
Fixed bug 4538 - validate image size when loading BMP files
IMG_bmp.c
     1.1 --- a/IMG_bmp.c	Tue Jul 30 10:16:02 2019 -0700
     1.2 +++ b/IMG_bmp.c	Tue Jul 30 11:00:12 2019 -0700
     1.3 @@ -351,6 +351,11 @@
     1.4              SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
     1.5          }
     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;