Fixed bug #457 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Sun, 15 Jul 2007 21:50:07 +0000
branchSDL-1.2
changeset 40769a7c62bbc8b3
parent 4075 0207ca19fd8f
child 4077 a9df0628d256
Fixed bug #457

Don't crash if passed a NULL overlay. The app crashes anyway, since
it's not checking the return value of the create call, but at least it's
not crashing in SDL anymore. :)
src/video/SDL_yuv.c
     1.1 --- a/src/video/SDL_yuv.c	Sun Jul 15 19:43:54 2007 +0000
     1.2 +++ b/src/video/SDL_yuv.c	Sun Jul 15 21:50:07 2007 +0000
     1.3 @@ -65,11 +65,18 @@
     1.4  
     1.5  int SDL_LockYUVOverlay(SDL_Overlay *overlay)
     1.6  {
     1.7 +	if ( overlay == NULL ) {
     1.8 +		SDL_SetError("Passed NULL overlay");
     1.9 +		return -1;
    1.10 +	}
    1.11  	return overlay->hwfuncs->Lock(current_video, overlay);
    1.12  }
    1.13  
    1.14  void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
    1.15  {
    1.16 +	if ( overlay == NULL ) {
    1.17 +		return;
    1.18 +	}
    1.19  	overlay->hwfuncs->Unlock(current_video, overlay);
    1.20  }
    1.21  
    1.22 @@ -79,6 +86,11 @@
    1.23  	int srcx, srcy, srcw, srch;
    1.24  	int dstx, dsty, dstw, dsth;
    1.25  
    1.26 +	if ( overlay == NULL || dstrect == NULL ) {
    1.27 +		SDL_SetError("Passed NULL overlay or dstrect");
    1.28 +		return -1;
    1.29 +	}
    1.30 +
    1.31  	/* Clip the rectangle to the screen area */
    1.32  	srcx = 0;
    1.33  	srcy = 0;
    1.34 @@ -128,10 +140,11 @@
    1.35  
    1.36  void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
    1.37  {
    1.38 -	if ( overlay ) {
    1.39 -		if ( overlay->hwfuncs ) {
    1.40 -			overlay->hwfuncs->FreeHW(current_video, overlay);
    1.41 -		}
    1.42 -		SDL_free(overlay);
    1.43 +	if ( overlay == NULL ) {
    1.44 +		return;
    1.45  	}
    1.46 +	if ( overlay->hwfuncs ) {
    1.47 +		overlay->hwfuncs->FreeHW(current_video, overlay);
    1.48 +	}
    1.49 +	SDL_free(overlay);
    1.50  }