Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Windows GetBasePath: fixed reallocation code.
  • Loading branch information
icculus committed May 28, 2015
1 parent 566316e commit aa43bee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/filesystem/windows/SDL_sysfilesystem.c
Expand Up @@ -58,20 +58,21 @@ SDL_GetBasePath(void)
}

while (SDL_TRUE) {
path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
if (!path) {
WCHAR *ptr = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
if (!ptr) {
SDL_free(path);
FreeLibrary(psapi);
SDL_OutOfMemory();
return NULL;
}
path = ptr;

len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
if (len != buflen) {
break;
}

/* buffer too small? Try again. */
SDL_free(path);
buflen *= 2;
}

Expand Down

0 comments on commit aa43bee

Please sign in to comment.