mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-31 14:29:14 +08:00
Don't create the SDL environment in SDL_setenv_unsafe()
We might be setting an environment variable along with other application code setting environment variables (like code in SteamAPI_InitEx()) before initializing SDL.
This commit is contained in:
+24
-8
@@ -337,7 +337,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
if (SDL_environment) {
|
||||||
|
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||||
|
}
|
||||||
|
|
||||||
return setenv(name, value, overwrite);
|
return setenv(name, value, overwrite);
|
||||||
}
|
}
|
||||||
@@ -352,7 +354,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
if (SDL_environment) {
|
||||||
|
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (getenv(name) != NULL) {
|
if (getenv(name) != NULL) {
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
@@ -376,7 +380,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
if (SDL_environment) {
|
||||||
|
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
|
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
|
||||||
@@ -407,7 +413,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
if (SDL_environment) {
|
||||||
|
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate memory for the variable
|
// Allocate memory for the variable
|
||||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||||
@@ -462,7 +470,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
if (SDL_environment) {
|
||||||
|
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||||
|
}
|
||||||
|
|
||||||
return unsetenv(name);
|
return unsetenv(name);
|
||||||
}
|
}
|
||||||
@@ -475,7 +485,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
if (SDL_environment) {
|
||||||
|
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||||
|
}
|
||||||
|
|
||||||
// Hope this environment uses the non-standard extension of removing the environment variable if it has no '='
|
// Hope this environment uses the non-standard extension of removing the environment variable if it has no '='
|
||||||
return putenv(name);
|
return putenv(name);
|
||||||
@@ -489,7 +501,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
if (SDL_environment) {
|
||||||
|
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!SetEnvironmentVariableA(name, NULL)) {
|
if (!SetEnvironmentVariableA(name, NULL)) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -506,7 +520,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
if (SDL_environment) {
|
||||||
|
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||||
|
}
|
||||||
|
|
||||||
if (environ) {
|
if (environ) {
|
||||||
len = SDL_strlen(name);
|
len = SDL_strlen(name);
|
||||||
|
|||||||
Reference in New Issue
Block a user