Windows SDL_GetBasePath: free string on failure.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 28 May 2015 15:36:27 -0400
changeset 9677 8201e3e3d026
parent 9676 edd750fa709c
child 9678 9e8323b058d6
Windows SDL_GetBasePath: free string on failure.
src/filesystem/windows/SDL_sysfilesystem.c
--- a/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 15:32:45 2015 -0400
+++ b/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 15:36:27 2015 -0400
@@ -58,14 +58,15 @@
     }
 
     while (SDL_TRUE) {
-        WCHAR *ptr = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
+        void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
         if (!ptr) {
             SDL_free(path);
             FreeLibrary(psapi);
             SDL_OutOfMemory();
             return NULL;
         }
-        path = ptr;
+
+        path = (WCHAR *) ptr;
 
         len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
         if (len != buflen) {
@@ -79,6 +80,7 @@
     FreeLibrary(psapi);
 
     if (len == 0) {
+        SDL_free(path);
         WIN_SetError("Couldn't locate our .exe");
         return NULL;
     }