comparison 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
comparison
equal deleted inserted replaced
455:a228badffb6c 456:b4e14b15af3c
360 360
361 /* Currently 1 and 4 bpp are not supported */ 361 /* Currently 1 and 4 bpp are not supported */
362 if ( bpp < 8 || bpp > 32 ) { 362 if ( bpp < 8 || bpp > 32 ) {
363 return(0); 363 return(0);
364 } 364 }
365 if ( (width == 0) || (height == 0) ) { 365 if ( (width <= 0) || (height <= 0) ) {
366 return(0); 366 return(0);
367 } 367 }
368 368
369 /* Search through the list valid of modes */ 369 /* Search through the list valid of modes */
370 memset(&format, 0, sizeof(format)); 370 memset(&format, 0, sizeof(format));
413 int supported; 413 int supported;
414 int native_bpp; 414 int native_bpp;
415 SDL_PixelFormat format; 415 SDL_PixelFormat format;
416 SDL_Rect **sizes; 416 SDL_Rect **sizes;
417 417
418 /* Check parameters */
419 if ( *BitsPerPixel < 8 || *BitsPerPixel > 32 ) {
420 SDL_SetError("Invalid bits per pixel (range is {8...32})");
421 return(0);
422 }
418 if ((*w <= 0) || (*h <= 0)) { 423 if ((*w <= 0) || (*h <= 0)) {
419 SDL_SetError("Invalid parameter"); 424 SDL_SetError("Invalid width or height");
420 return(0); 425 return(0);
421 } 426 }
422 427
423 /* Try the original video mode, get the closest depth */ 428 /* Try the original video mode, get the closest depth */
424 native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags); 429 native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags);