changeset 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 a228badffb6c
children d0ab9718bf91
files src/video/SDL_video.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
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);
 	}