Set the error after freeing stuff, just in case one of those functions resets SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 10 Jul 2007 19:03:44 +0000
branchSDL-1.2
changeset 40408515468091e3
parent 4039 7fd9a811efc7
child 4041 1c291c47cf1e
Set the error after freeing stuff, just in case one of those functions resets
the error string.
src/file/SDL_rwops.c
     1.1 --- a/src/file/SDL_rwops.c	Tue Jul 10 18:56:08 2007 +0000
     1.2 +++ b/src/file/SDL_rwops.c	Tue Jul 10 19:03:44 2007 +0000
     1.3 @@ -91,10 +91,10 @@
     1.4  		wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
     1.5  
     1.6  		if ( MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == 0 ) {
     1.7 -			SDL_SetError("Unable to convert filename to Unicode");
     1.8  			SDL_stack_free(filenameW);
     1.9  			SDL_free(context->hidden.win32io.buffer.data);
    1.10  			context->hidden.win32io.buffer.data = NULL;
    1.11 +			SDL_SetError("Unable to convert filename to Unicode");
    1.12  			return -1;
    1.13  		}
    1.14  		h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ, 
    1.15 @@ -113,9 +113,9 @@
    1.16  #endif /* _WIN32_WCE */
    1.17  
    1.18  	if (h==INVALID_HANDLE_VALUE) {
    1.19 -		SDL_SetError("Couldn't open %s",filename);
    1.20  		SDL_free(context->hidden.win32io.buffer.data);
    1.21  		context->hidden.win32io.buffer.data = NULL;
    1.22 +		SDL_SetError("Couldn't open %s",filename);
    1.23  		return -2; /* failed (CreateFile) */
    1.24  	}
    1.25  	context->hidden.win32io.h = h;