From aba703b01a1e5df10c7df6889b9151af18b4b266 Mon Sep 17 00:00:00 2001 From: Jason Zou Date: Thu, 26 Oct 2023 15:54:20 -0700 Subject: [PATCH] use SimbaEngineSDK version for sf_getenv --- lib/platform.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/platform.c b/lib/platform.c index 75f4c69e9f..00f12fc3e6 100755 --- a/lib/platform.c +++ b/lib/platform.c @@ -268,12 +268,12 @@ int STDCALL sf_setenv(const char *name, const char *value) { char * STDCALL sf_getenv(const char *name) { #ifdef _WIN32 - static char buf[BUFSIZ]; - size_t len = 0; // We don't use it, but Windows version doesn't like to pass NULL as lenght pointer. It crashes. - return getenv_s(&len, buf, sizeof(buf) - 1, name) ? NULL : buf; -#else - return getenv(name); -#endif + char* result = NULL; + return _dupenv_s(&result, NULL, name) ? NULL : result; +# else + char* result = getenv(name); + return result ? strdup(result) : NULL; +# endif } int STDCALL sf_unsetenv(const char *name) {