Windows SDL_GetBasePath: free string on failure.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 28 May 2015 15:36:27 -0400
changeset 96778201e3e3d026
parent 9676 edd750fa709c
child 9678 9e8323b058d6
Windows SDL_GetBasePath: free string on failure.
src/filesystem/windows/SDL_sysfilesystem.c
     1.1 --- a/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 15:32:45 2015 -0400
     1.2 +++ b/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 15:36:27 2015 -0400
     1.3 @@ -58,14 +58,15 @@
     1.4      }
     1.5  
     1.6      while (SDL_TRUE) {
     1.7 -        WCHAR *ptr = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
     1.8 +        void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
     1.9          if (!ptr) {
    1.10              SDL_free(path);
    1.11              FreeLibrary(psapi);
    1.12              SDL_OutOfMemory();
    1.13              return NULL;
    1.14          }
    1.15 -        path = ptr;
    1.16 +
    1.17 +        path = (WCHAR *) ptr;
    1.18  
    1.19          len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
    1.20          if (len != buflen) {
    1.21 @@ -79,6 +80,7 @@
    1.22      FreeLibrary(psapi);
    1.23  
    1.24      if (len == 0) {
    1.25 +        SDL_free(path);
    1.26          WIN_SetError("Couldn't locate our .exe");
    1.27          return NULL;
    1.28      }