Mercurial > sdl-ios-xcode
diff src/video/SDL_video.c @ 456:b4e14b15af3c
Fixed crash with invalid bpp in SDL_SetVideoMode()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 20 Aug 2002 04:44:36 +0000 |
parents | 8a43e0cbf02f |
children | a888b3ae31ff |
line wrap: on
line diff
--- 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); }