SDL: SDL_CreateEnvironment() fills the environment with a non-zero parameter

From aa7357a14d74fe8ad99363b505a10e6917d4fc66 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 14 Sep 2024 09:18:07 -0700
Subject: [PATCH] SDL_CreateEnvironment() fills the environment with a non-zero
 parameter

---
 include/SDL3/SDL_stdinc.h          | 6 +++---
 src/dialog/unix/SDL_zenitydialog.c | 2 +-
 src/misc/unix/SDL_sysurl.c         | 2 +-
 src/stdlib/SDL_getenv.c            | 6 +++---
 test/testprocess.c                 | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h
index 21113ac6af8b5..b10de17828acc 100644
--- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h
@@ -1030,11 +1030,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_CleanupEnvironment(void);
 /**
  * Create a set of environment variables
  *
- * \param empty SDL_TRUE to create an empty environment, SDL_FALSE to initialize it from the C runtime environment.
+ * \param populated SDL_TRUE to initialize it from the C runtime environment, SDL_FALSE to create an empty environment.
  * \returns a pointer to the new environment or NULL on failure; call SDL_GetError()
  *          for more information.
  *
- * \threadsafety If `empty` is SDL_TRUE, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
+ * \threadsafety If `populated` is SDL_FALSE, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
  *
  * \since This function is available since SDL 3.0.0.
  *
@@ -1044,7 +1044,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CleanupEnvironment(void);
  * \sa SDL_UnsetEnvironmentVariable
  * \sa SDL_DestroyEnvironment
  */
-extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(SDL_bool empty);
+extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(SDL_bool populated);
 
 /**
  * Get the value of a variable in the environment.
diff --git a/src/dialog/unix/SDL_zenitydialog.c b/src/dialog/unix/SDL_zenitydialog.c
index b816d02262318..17116e39193ab 100644
--- a/src/dialog/unix/SDL_zenitydialog.c
+++ b/src/dialog/unix/SDL_zenitydialog.c
@@ -207,7 +207,7 @@ static void run_zenity(zenityArgs* arg_struct)
         goto done;
     }
 
-    env = SDL_CreateEnvironment(SDL_FALSE);
+    env = SDL_CreateEnvironment(true);
     if (!env) {
         goto done;
     }
diff --git a/src/misc/unix/SDL_sysurl.c b/src/misc/unix/SDL_sysurl.c
index 69517f1627208..e60b40981323b 100644
--- a/src/misc/unix/SDL_sysurl.c
+++ b/src/misc/unix/SDL_sysurl.c
@@ -41,7 +41,7 @@ bool SDL_SYS_OpenURL(const char *url)
     SDL_Process *process = NULL;
     bool result = false;
 
-    env = SDL_CreateEnvironment(SDL_FALSE);
+    env = SDL_CreateEnvironment(true);
     if (!env) {
         goto done;
     }
diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c
index 7c0beb6e5c031..c29fc3149cffe 100644
--- a/src/stdlib/SDL_getenv.c
+++ b/src/stdlib/SDL_getenv.c
@@ -329,7 +329,7 @@ static SDL_Environment *SDL_environment;
 SDL_Environment *SDL_GetEnvironment(void)
 {
     if (!SDL_environment) {
-        SDL_environment = SDL_CreateEnvironment(false);
+        SDL_environment = SDL_CreateEnvironment(true);
     }
     return SDL_environment;
 }
@@ -344,7 +344,7 @@ void SDL_CleanupEnvironment(void)
     }
 }
 
-SDL_Environment *SDL_CreateEnvironment(SDL_bool empty)
+SDL_Environment *SDL_CreateEnvironment(SDL_bool populated)
 {
     SDL_Environment *env = SDL_calloc(1, sizeof(*env));
     if (!env) {
@@ -360,7 +360,7 @@ SDL_Environment *SDL_CreateEnvironment(SDL_bool empty)
     // Don't fail if we can't create a mutex (e.g. on a single-thread environment)
     env->lock = SDL_CreateMutex();
 
-    if (!empty) {
+    if (populated) {
 #ifdef SDL_PLATFORM_WINDOWS
         LPWCH strings = GetEnvironmentStringsW();
         if (strings) {
diff --git a/test/testprocess.c b/test/testprocess.c
index 6f59c5ad22800..0c6a13886b6f7 100644
--- a/test/testprocess.c
+++ b/test/testprocess.c
@@ -40,7 +40,7 @@ static char **DuplicateEnvironment(const char *key0, ...)
     va_list ap;
     const char *keyN;
     SDL_Environment *env = SDL_GetEnvironment();
-    SDL_Environment *new_env = SDL_CreateEnvironment(SDL_TRUE);
+    SDL_Environment *new_env = SDL_CreateEnvironment(SDL_FALSE);
     char **result;
 
     if (key0) {