Fixed bug 4538 - validate image size when loading BMP files
authorSam Lantinga <slouken@libsdl.org>
Tue, 30 Jul 2019 11:00:00 -0700
changeset 12959e7ba650a643a
parent 12958 b810b78d32cc
child 12961 8dbdfc918c7a
Fixed bug 4538 - validate image size when loading BMP files
src/video/SDL_bmp.c
     1.1 --- a/src/video/SDL_bmp.c	Thu Jul 25 08:05:13 2019 -0500
     1.2 +++ b/src/video/SDL_bmp.c	Tue Jul 30 11:00:00 2019 -0700
     1.3 @@ -226,6 +226,11 @@
     1.4              SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
     1.5          }
     1.6      }
     1.7 +    if (biWidth <= 0 || biHeight == 0) {
     1.8 +        SDL_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;