Skip to content
Permalink
Browse files

Windows GetBasePath: fixed reallocation code.

  • Loading branch information
icculus committed May 28, 2015
1 parent 566316e commit aa43bee434e1e69b937cdc46edc70aabbf1e7cae
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/filesystem/windows/SDL_sysfilesystem.c
@@ -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;
}

0 comments on commit aa43bee

Please sign in to comment.