Author: jra
Date: 2006-06-20 18:14:19 +0000 (Tue, 20 Jun 2006)
New Revision: 16419

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16419

Log:
Fix Klocwork #1674. Null deref.
Jeremy.

Modified:
   trunk/source/lib/util_unistr.c


Changeset:
Modified: trunk/source/lib/util_unistr.c
===================================================================
--- trunk/source/lib/util_unistr.c      2006-06-20 16:59:48 UTC (rev 16418)
+++ trunk/source/lib/util_unistr.c      2006-06-20 18:14:19 UTC (rev 16419)
@@ -98,8 +98,10 @@
        /* 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 @@
 
 #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
 }
 

Reply via email to