Coverity #1321035, #1321423 fixed 28/18328/2
Dhruv Khattar [Wed, 29 Jun 2016 22:03:07 +0000 (03:03 +0530)]
Change-Id: I948245f3ce6f76eb64dbaa20365b2c099ee30022

scilab/modules/functions_manager/src/cpp/funcmanager.cpp

index c276174..3d53013 100644 (file)
@@ -139,11 +139,8 @@ bool FuncManager::AppendModules()
         if (doc == NULL)
         {
             std::cout << "Error: Could not parse file " << pstTemp << std::endl;
-            if (encoding)
-            {
-                free(encoding);
-                encoding = NULL;
-            }
+            free(encoding);
+            encoding = NULL;
             FREE(pstTemp);
             return false;
         }
@@ -166,6 +163,10 @@ bool FuncManager::AppendModules()
                     {
                         /* we found the tag name */
                         const char *str = (const char*)attrib->children->content;
+                        if (name)
+                        {
+                            FREE(name);
+                        }
                         name = os_strdup(str);
                     }
                     else if (xmlStrEqual(attrib->name, (const xmlChar*)"activate"))
@@ -217,11 +218,8 @@ bool FuncManager::AppendModules()
     {
         std::cout << "Error: Not a valid module file " << pstTemp << " (encoding not 'utf-8') Encoding '" << encoding << "' found." << std::endl;
     }
-    if (encoding)
-    {
-        free(encoding);
-        encoding = NULL;
-    }
+    free(encoding);
+    encoding = NULL;
 
     ConfigVariable::setModuleList(m_ModuleName);
     FREE(pstTemp);