Windows GetBasePath: fixed reallocation code.
--HG-- extra : rebase_source : 3b2cf31f9d42d7925e3200dcae98af36159a5bc0
This commit is contained in:
parent
ae904749d0
commit
b22d989ad8
1 changed files with 4 additions and 3 deletions
|
@ -58,12 +58,14 @@ SDL_GetBasePath(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (SDL_TRUE) {
|
while (SDL_TRUE) {
|
||||||
path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
|
WCHAR *ptr = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
|
||||||
if (!path) {
|
if (!ptr) {
|
||||||
|
SDL_free(path);
|
||||||
FreeLibrary(psapi);
|
FreeLibrary(psapi);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
path = ptr;
|
||||||
|
|
||||||
len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
|
len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
|
||||||
if (len != buflen) {
|
if (len != buflen) {
|
||||||
|
@ -71,7 +73,6 @@ SDL_GetBasePath(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer too small? Try again. */
|
/* buffer too small? Try again. */
|
||||||
SDL_free(path);
|
|
||||||
buflen *= 2;
|
buflen *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue