# HG changeset patch # User Ryan C. Gordon # Date 1184094224 0 # Node ID 8515468091e347227b553f8353d1a10c00ba1d8e # Parent 7fd9a811efc73b09928a9938aeaa260a952c166b Set the error after freeing stuff, just in case one of those functions resets the error string. diff -r 7fd9a811efc7 -r 8515468091e3 src/file/SDL_rwops.c --- 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;