changeset 3964:3dc92ff218dd SDL-1.2

Clean up have-initialized resources in some failing edge cases. Maybe fixes Bugzilla #426.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 15 Jun 2007 06:57:31 +0000
parents a9ad5257f794
children 19d708301fab
files src/video/x11/SDL_x11video.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/x11/SDL_x11video.c	Fri Jun 15 06:49:14 2007 +0000
+++ b/src/video/x11/SDL_x11video.c	Fri Jun 15 06:57:31 2007 +0000
@@ -408,7 +408,7 @@
 	}
     }
 
-    /* Setup the communication with the IM server */
+	/* Setup the communication with the IM server */
 	SDL_IM = NULL;
 	SDL_IC = NULL;
 
@@ -483,6 +483,8 @@
 	 */
 	GFX_Display = XOpenDisplay(display);
 	if ( GFX_Display == NULL ) {
+		XCloseDisplay(SDL_Display);
+		SDL_Display = NULL;
 		SDL_SetError("Couldn't open X11 display");
 		return(-1);
 	}
@@ -508,8 +510,13 @@
 #endif /* NO_SHARED_MEMORY */
 
 	/* Get the available video modes */
-	if(X11_GetVideoModes(this) < 0)
+	if(X11_GetVideoModes(this) < 0) {
+		XCloseDisplay(GFX_Display);
+		GFX_Display = NULL;
+		XCloseDisplay(SDL_Display);
+		SDL_Display = NULL;
 	    return -1;
+	}
 
 	/* Determine the current screen size */
 	this->info.current_w = DisplayWidth(SDL_Display, SDL_Screen);