# HG changeset patch # User Sam Lantinga # Date 1029818676 0 # Node ID b4e14b15af3cfcd19de31aca9223c2cc360582b5 # Parent a228badffb6cc706cf16c4db11e9759ea8e2373b Fixed crash with invalid bpp in SDL_SetVideoMode() diff -r a228badffb6c -r b4e14b15af3c src/video/SDL_video.c --- a/src/video/SDL_video.c Tue Aug 20 00:27:37 2002 +0000 +++ b/src/video/SDL_video.c Tue Aug 20 04:44:36 2002 +0000 @@ -362,7 +362,7 @@ if ( bpp < 8 || bpp > 32 ) { return(0); } - if ( (width == 0) || (height == 0) ) { + if ( (width <= 0) || (height <= 0) ) { return(0); } @@ -415,8 +415,13 @@ 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); }