From dc36abe3a234ddf7973a3cc19c06d3cef17fa4e1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Jun 2006 18:14:33 +0000 Subject: r16420: Fix Klocwork #1674. Null deref. Jeremy. (This used to be commit f5dddf339ee3a867e21f34a81bd0b33195b7397d) --- source3/lib/util_unistr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/lib/util_unistr.c') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index eef484148d..a0015c265f 100644 --- a/source3/lib/util_unistr.c +++ b/source3/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 } -- cgit