From faf9e62679540cefda2c2a5c494c78e1a9240344 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 20 Aug 2002 04:44:36 +0000 Subject: [PATCH] Fixed crash with invalid bpp in SDL_SetVideoMode() --- src/video/SDL_video.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 3027f0d22..32e9e0e44 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -362,7 +362,7 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) if ( bpp < 8 || bpp > 32 ) { return(0); } - if ( (width == 0) || (height == 0) ) { + if ( (width <= 0) || (height <= 0) ) { return(0); } @@ -415,8 +415,13 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) SDL_PixelFormat format; 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)) { - SDL_SetError("Invalid parameter"); + SDL_SetError("Invalid width or height"); return(0); }