summaryrefslogtreecommitdiff
path: root/source/lib/util_unistr.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib/util_unistr.c')
-rw-r--r--source/lib/util_unistr.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index eef484148db..a0015c265fb 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -98,8 +98,10 @@ void load_case_tables(void)
/* Get the name of the current locale. */
old_locale = setlocale(LC_ALL, NULL);
- /* Save it as it is in static storage. */
- saved_locale = SMB_STRDUP(old_locale);
+ if (old_locale) {
+ /* Save it as it is in static storage. */
+ saved_locale = SMB_STRDUP(old_locale);
+ }
/* We set back the locale to C to get ASCII-compatible toupper/lower functions. */
setlocale(LC_ALL, "C");
@@ -139,8 +141,10 @@ void load_case_tables(void)
#ifdef HAVE_SETLOCALE
/* Restore the old locale. */
- setlocale (LC_ALL, saved_locale);
- SAFE_FREE(saved_locale);
+ if (saved_locale) {
+ setlocale (LC_ALL, saved_locale);
+ SAFE_FREE(saved_locale);
+ }
#endif
}