File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -440,7 +440,16 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
440440
441441static void SDL_InitDynamicAPILocked (void )
442442{
443- char * libname = SDL_getenv_REAL (SDL_DYNAMIC_API_ENVVAR );
443+ /* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
444+ #if defined(WIN32 ) || defined(_WIN32 ) || defined(__CYGWIN__ )
445+ /* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
446+ char envbuf [512 ]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
447+ const DWORD rc = GetEnvironmentVariableA (SDL_DYNAMIC_API_ENVVAR , envbuf , (DWORD ) sizeof (envbuf ));
448+ char * libname = ((rc != 0 ) && (rc < sizeof (envbuf ))) ? envbuf : NULL ;
449+ #else
450+ char * libname = getenv (SDL_DYNAMIC_API_ENVVAR );
451+ #endif
452+
444453 SDL_DYNAPI_ENTRYFN entry = NULL ; /* funcs from here by default. */
445454 SDL_bool use_internal = SDL_TRUE ;
446455
You can’t perform that action at this time.
0 commit comments