2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Better handling of setlocale() returning NULL.

This commit is contained in:
Todd C. Miller
2015-06-19 16:49:02 -06:00
parent c36415417f
commit d8dd6512ce
2 changed files with 8 additions and 3 deletions

View File

@@ -84,7 +84,9 @@ sudoers_setlocale(int newlocale, int *prevlocale)
current_locale = SUDOERS_LOCALE_USER;
res = setlocale(LC_ALL, user_locale ? user_locale : "");
if (res != NULL && user_locale == NULL) {
user_locale = strdup(setlocale(LC_ALL, NULL));
user_locale = setlocale(LC_ALL, NULL);
if (user_locale != NULL)
user_locale = strdup(user_locale);
if (user_locale == NULL)
res = NULL;
}