changeset 4076:9a7c62bbc8b3 SDL-1.2

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. :)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Jul 2007 21:50:07 +0000
parents 0207ca19fd8f
children a9df0628d256
files src/video/SDL_yuv.c
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_yuv.c	Sun Jul 15 19:43:54 2007 +0000
+++ b/src/video/SDL_yuv.c	Sun Jul 15 21:50:07 2007 +0000
@@ -65,11 +65,18 @@
 
 int SDL_LockYUVOverlay(SDL_Overlay *overlay)
 {
+	if ( overlay == NULL ) {
+		SDL_SetError("Passed NULL overlay");
+		return -1;
+	}
 	return overlay->hwfuncs->Lock(current_video, overlay);
 }
 
 void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
 {
+	if ( overlay == NULL ) {
+		return;
+	}
 	overlay->hwfuncs->Unlock(current_video, overlay);
 }
 
@@ -79,6 +86,11 @@
 	int srcx, srcy, srcw, srch;
 	int dstx, dsty, dstw, dsth;
 
+	if ( overlay == NULL || dstrect == NULL ) {
+		SDL_SetError("Passed NULL overlay or dstrect");
+		return -1;
+	}
+
 	/* Clip the rectangle to the screen area */
 	srcx = 0;
 	srcy = 0;
@@ -128,10 +140,11 @@
 
 void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
 {
-	if ( overlay ) {
-		if ( overlay->hwfuncs ) {
-			overlay->hwfuncs->FreeHW(current_video, overlay);
-		}
-		SDL_free(overlay);
+	if ( overlay == NULL ) {
+		return;
 	}
+	if ( overlay->hwfuncs ) {
+		overlay->hwfuncs->FreeHW(current_video, overlay);
+	}
+	SDL_free(overlay);
 }