Coverity #1099102, #1099103, #1321340 fixed 63/18363/3
Dhruv Khattar [Tue, 12 Jul 2016 20:45:48 +0000 (01:45 +0530)]
Change-Id: I4439550225e21ed7aba8f74dfeaf77490e6f6de0

scilab/modules/localization/src/c/InitializeLocalization.c
scilab/modules/localization/src/c/charEncoding.c

index f82ad82..d431659 100644 (file)
@@ -64,11 +64,8 @@ BOOL InitializeLocalization(void)
     {
         /* source tree and classic build */
         previousPathLocales = os_strdup(pathLocales);
-        if (pathLocales)
-        {
-            FREE(pathLocales);
-            pathLocales = NULL;
-        }
+        FREE(pathLocales);
+        pathLocales = NULL;
 
         pathLocales = (char *)MALLOC(sizeof(char) * (strlen(SCIpath) + strlen("/..") + strlen(PATHLOCALIZATIONFILE) + 1));
         strcpy(pathLocales, SCIpath);
@@ -103,16 +100,10 @@ BOOL InitializeLocalization(void)
                 FREE(previousPathLocales);
                 previousPathLocales = NULL;
             }
-            if (pathLocales)
-            {
-                FREE(pathLocales);
-                pathLocales = NULL;
-            }
-            if (SCIpath)
-            {
-                FREE(SCIpath);
-                SCIpath = NULL;
-            }
+            FREE(pathLocales);
+            pathLocales = NULL;
+            FREE(SCIpath);
+            SCIpath = NULL;
             return FALSE;
         }
         if (previousPathLocales)
@@ -122,16 +113,10 @@ BOOL InitializeLocalization(void)
         }
     }
 
-    if (SCIpath)
-    {
-        FREE(SCIpath);
-        SCIpath = NULL;
-    }
-    if (pathLocales)
-    {
-        FREE(pathLocales);
-        pathLocales = NULL;
-    }
+    FREE(SCIpath);
+    SCIpath = NULL;
+    FREE(pathLocales);
+    pathLocales = NULL;
 
     /* set domain for future gettext() calls */
     ret = textdomain(NAMELOCALIZATIONDOMAIN);
index bb4d845..e0ee5b6 100644 (file)
@@ -202,13 +202,15 @@ char *wide_string_to_UTF8(const wchar_t *_wide)
     size_t iLeftIn = 0;
     size_t iLeftOut = 0;
     char* pOut = NULL;
-    iconv_t cd_UTF16_to_UTF8 = iconv_open("UTF-8", "WCHAR_T");
+    iconv_t cd_UTF16_to_UTF8;
 
     if (_wide == NULL)
     {
         return NULL;
     }
 
+    cd_UTF16_to_UTF8 = iconv_open("UTF-8", "WCHAR_T");
+
     pSaveIn = (wchar_t*)_wide;
     iLeftIn = wcslen(_wide) * sizeof(wchar_t);