Clean up have-initialized resources in some failing edge cases. SDL-1.2
authorRyan C. Gordon
Fri, 15 Jun 2007 06:57:31 +0000
branchSDL-1.2
changeset 39643dc92ff218dd
parent 3963 a9ad5257f794
child 3965 19d708301fab
Clean up have-initialized resources in some failing edge cases.

Maybe fixes Bugzilla #426.
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/x11/SDL_x11video.c	Fri Jun 15 06:49:14 2007 +0000
     1.2 +++ b/src/video/x11/SDL_x11video.c	Fri Jun 15 06:57:31 2007 +0000
     1.3 @@ -408,7 +408,7 @@
     1.4  	}
     1.5      }
     1.6  
     1.7 -    /* Setup the communication with the IM server */
     1.8 +	/* Setup the communication with the IM server */
     1.9  	SDL_IM = NULL;
    1.10  	SDL_IC = NULL;
    1.11  
    1.12 @@ -483,6 +483,8 @@
    1.13  	 */
    1.14  	GFX_Display = XOpenDisplay(display);
    1.15  	if ( GFX_Display == NULL ) {
    1.16 +		XCloseDisplay(SDL_Display);
    1.17 +		SDL_Display = NULL;
    1.18  		SDL_SetError("Couldn't open X11 display");
    1.19  		return(-1);
    1.20  	}
    1.21 @@ -508,8 +510,13 @@
    1.22  #endif /* NO_SHARED_MEMORY */
    1.23  
    1.24  	/* Get the available video modes */
    1.25 -	if(X11_GetVideoModes(this) < 0)
    1.26 +	if(X11_GetVideoModes(this) < 0) {
    1.27 +		XCloseDisplay(GFX_Display);
    1.28 +		GFX_Display = NULL;
    1.29 +		XCloseDisplay(SDL_Display);
    1.30 +		SDL_Display = NULL;
    1.31  	    return -1;
    1.32 +	}
    1.33  
    1.34  	/* Determine the current screen size */
    1.35  	this->info.current_w = DisplayWidth(SDL_Display, SDL_Screen);