23 lines
778 B
Diff
23 lines
778 B
Diff
|
From 85138c1ec673e05263ae666baf61f79384daf7e0 Mon Sep 17 00:00:00 2001
|
||
|
From: Sam Lantinga <slouken@libsdl.org>
|
||
|
Date: Tue, 30 Jul 2019 11:00:00 -0700
|
||
|
Subject: Fixed bug 4538 - validate image size when loading BMP files
|
||
|
|
||
|
|
||
|
diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
|
||
|
index 0b68918cc..a06b0c94c 100644
|
||
|
--- a/src/video/SDL_bmp.c
|
||
|
+++ b/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;
|