From 2b853121fe5b88e7e937a3da05a9708d4fa27db6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 9 Aug 2024 13:26:49 -0700 Subject: [PATCH] Allow environment hint overrides before hints are initialized Fixes https://github.com/libsdl-org/SDL/issues/10514 --- src/SDL_hints.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 48b3e6ac79..8a79ee16b7 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -196,23 +196,21 @@ const char *SDL_GetHint(const char *name) return NULL; } - const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE); - if (!hints) { - return NULL; - } - const char *retval = SDL_getenv(name); - SDL_LockProperties(hints); + const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE); + if (hints) { + SDL_LockProperties(hints); - SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL); - if (hint) { - if (!retval || hint->priority == SDL_HINT_OVERRIDE) { - retval = SDL_GetPersistentString(hint->value); + SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL); + if (hint) { + if (!retval || hint->priority == SDL_HINT_OVERRIDE) { + retval = SDL_GetPersistentString(hint->value); + } } - } - SDL_UnlockProperties(hints); + SDL_UnlockProperties(hints); + } return retval; }