Commit 9e7b2297 authored by Sam Lantinga's avatar Sam Lantinga

Fixed crash with invalid bpp in SDL_SetVideoMode()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40457
parent f7868447
...@@ -362,7 +362,7 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) ...@@ -362,7 +362,7 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
if ( bpp < 8 || bpp > 32 ) { if ( bpp < 8 || bpp > 32 ) {
return(0); return(0);
} }
if ( (width == 0) || (height == 0) ) { if ( (width <= 0) || (height <= 0) ) {
return(0); return(0);
} }
...@@ -415,8 +415,13 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) ...@@ -415,8 +415,13 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
SDL_PixelFormat format; SDL_PixelFormat format;
SDL_Rect **sizes; SDL_Rect **sizes;
/* Check parameters */
if ( *BitsPerPixel < 8 || *BitsPerPixel > 32 ) {
SDL_SetError("Invalid bits per pixel (range is {8...32})");
return(0);
}
if ((*w <= 0) || (*h <= 0)) { if ((*w <= 0) || (*h <= 0)) {
SDL_SetError("Invalid parameter"); SDL_SetError("Invalid width or height");
return(0); return(0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment