SDL: Better fix for initializing Android environment variables

From ea2e2e451d17550365c8610e799e7b7857dd6a24 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 20 Sep 2024 11:09:48 -0700
Subject: [PATCH] Better fix for initializing Android environment variables

---
 src/core/android/SDL_android.c | 3 ++-
 src/stdlib/SDL_getenv.c        | 7 +------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 6f9db679e2386..e1e18c3cad7c4 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -1525,7 +1525,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)(
     const char *utfvalue = (*env)->GetStringUTFChars(env, value, NULL);
 
     // This is only called at startup, to initialize the environment
-    SDL_setenv_unsafe(utfname, utfvalue, 1);
+    // Note that we call setenv() directly to avoid affecting SDL environments
+    setenv(utfname, utfvalue, 1);
 
     (*env)->ReleaseStringUTFChars(env, name, utfname);
     (*env)->ReleaseStringUTFChars(env, value, utfvalue);
diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c
index a02112bd71b6a..6b691e3df1513 100644
--- a/src/stdlib/SDL_getenv.c
+++ b/src/stdlib/SDL_getenv.c
@@ -122,12 +122,7 @@ SDL_Environment *SDL_CreateEnvironment(bool populated)
 #else
 #ifdef SDL_PLATFORM_ANDROID
         // Make sure variables from the application manifest are available
-        static bool initializing;
-        if (!initializing) {
-            initializing = true;
-            Android_JNI_GetManifestEnvironmentVariables();
-            initializing = false;
-        }
+        Android_JNI_GetManifestEnvironmentVariables();
 #endif
         char **strings = environ;
         if (strings) {