From 49a702dd58581694c2e8999df2fa225dad0738c4 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 29 Nov 2025 19:38:21 -0500 Subject: [PATCH] libroot/locale: Only set all locales if we checked the whole set. If we only checked one, then of course we can't set LC_ALL, as that will override ones we didn't verify were the same. Seems this code has been wrong since it was first imported in 2010. Fixes #19446. --- src/system/libroot/posix/locale/LocaleInternal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/posix/locale/LocaleInternal.cpp b/src/system/libroot/posix/locale/LocaleInternal.cpp index 16d5aafd9b..6557133819 100644 --- a/src/system/libroot/posix/locale/LocaleInternal.cpp +++ b/src/system/libroot/posix/locale/LocaleInternal.cpp @@ -49,6 +49,7 @@ GetLocalesFromEnvironment(int category, const char** locales) to = LC_LAST; } else from = to = category; + bool haveDifferentLocales = false; locale = NULL; for (int lc = from; lc <= to; lc++) { @@ -62,7 +63,7 @@ GetLocalesFromEnvironment(int category, const char** locales) if (lastLocale != NULL && strcasecmp(locale, lastLocale) != 0) haveDifferentLocales = true; } - if (!haveDifferentLocales) { + if (from == 1 && to == LC_LAST && !haveDifferentLocales) { // we can set all locales at once locales[LC_ALL] = locale; }