locale-util: filter out non-UTF-8 locales even when failed to parse $SYSTEMD_LIST_NON_UTF8_LOCALES

This commit is contained in:
Yu Watanabe
2025-04-13 04:59:26 +09:00
parent 90abb64fd5
commit a4a5ee4cd1
+5 -4
View File
@@ -220,7 +220,10 @@ int get_locales(char ***ret) {
locales = set_free(locales);
r = getenv_bool("SYSTEMD_LIST_NON_UTF8_LOCALES");
if (IN_SET(r, -ENXIO, 0)) {
if (r <= 0) {
if (!IN_SET(r, -ENXIO, 0))
log_debug_errno(r, "Failed to parse $SYSTEMD_LIST_NON_UTF8_LOCALES as boolean, ignoring: %m");
char **a, **b;
/* Filter out non-UTF-8 locales, because it's 2019, by default */
@@ -234,9 +237,7 @@ int get_locales(char ***ret) {
}
*b = NULL;
} else if (r < 0)
log_debug_errno(r, "Failed to parse $SYSTEMD_LIST_NON_UTF8_LOCALES as boolean");
}
strv_sort(l);