Skip to content

Commit

Permalink
Windows SDL_GetBasePath: free string on failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 28, 2015
1 parent aa43bee commit 4d1626d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/filesystem/windows/SDL_sysfilesystem.c
Expand Up @@ -58,14 +58,15 @@ SDL_GetBasePath(void)
}

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) {
Expand All @@ -79,6 +80,7 @@ SDL_GetBasePath(void)
FreeLibrary(psapi);

if (len == 0) {
SDL_free(path);
WIN_SetError("Couldn't locate our .exe");
return NULL;
}
Expand Down

0 comments on commit 4d1626d

Please sign in to comment.