Fixed crash with invalid bpp in SDL_SetVideoMode()
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40457
This commit is contained in:
parent
f786844714
commit
9e7b2297be
1 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue