Browse Source

Fixed bug 4538 - validate image size when loading BMP files

Sam Lantinga 5 years ago
parent
commit
97fefd0509
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/video/SDL_bmp.c

+ 5 - 0
src/video/SDL_bmp.c

@@ -226,6 +226,11 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
             SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
         }
     }
+    if (biWidth <= 0 || biHeight == 0) {
+        SDL_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight);
+        was_error = SDL_TRUE;
+        goto done;
+    }
     if (biHeight < 0) {
         topDown = SDL_TRUE;
         biHeight = -biHeight;