mirror of https://github.com/libsdl-org/SDL.git
dynapi: Don't use SDL_getenv; it might malloc before the app sets an allocator.
Use platform-specific code instead, so SDL's allocator never comes into play.
This commit is contained in:
parent
ed7e7edb70
commit
d2693d4c7d
|
|
@ -440,7 +440,16 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
|||
|
||||
static void SDL_InitDynamicAPILocked(void)
|
||||
{
|
||||
char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR);
|
||||
/* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
|
||||
/* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
|
||||
char envbuf[512]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
|
||||
const DWORD rc = GetEnvironmentVariableA(SDL_DYNAMIC_API_ENVVAR, envbuf, (DWORD) sizeof (envbuf));
|
||||
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
|
||||
#else
|
||||
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR);
|
||||
#endif
|
||||
|
||||
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
||||
SDL_bool use_internal = SDL_TRUE;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue