changeset 4040:8515468091e3 SDL-1.2

Set the error after freeing stuff, just in case one of those functions resets the error string.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 10 Jul 2007 19:03:44 +0000
parents 7fd9a811efc7
children 1c291c47cf1e
files src/file/SDL_rwops.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/file/SDL_rwops.c	Tue Jul 10 18:56:08 2007 +0000
+++ b/src/file/SDL_rwops.c	Tue Jul 10 19:03:44 2007 +0000
@@ -91,10 +91,10 @@
 		wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
 
 		if ( MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == 0 ) {
-			SDL_SetError("Unable to convert filename to Unicode");
 			SDL_stack_free(filenameW);
 			SDL_free(context->hidden.win32io.buffer.data);
 			context->hidden.win32io.buffer.data = NULL;
+			SDL_SetError("Unable to convert filename to Unicode");
 			return -1;
 		}
 		h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ, 
@@ -113,9 +113,9 @@
 #endif /* _WIN32_WCE */
 
 	if (h==INVALID_HANDLE_VALUE) {
-		SDL_SetError("Couldn't open %s",filename);
 		SDL_free(context->hidden.win32io.buffer.data);
 		context->hidden.win32io.buffer.data = NULL;
+		SDL_SetError("Couldn't open %s",filename);
 		return -2; /* failed (CreateFile) */
 	}
 	context->hidden.win32io.h = h;