Windows GetBasePath: fixed reallocation code.

This commit is contained in:
Ryan C. Gordon 2015-05-28 15:32:45 -04:00
parent 566316e052
commit aa43bee434

View File

@ -58,12 +58,14 @@ 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) {
@ -71,7 +73,6 @@ SDL_GetBasePath(void)
}
/* buffer too small? Try again. */
SDL_free(path);
buflen *= 2;
}