Coverity: Core module errors fixed
[scilab.git] / scilab / modules / core / src / c / loadversion.c
index ed0d3d0..95b5f93 100644 (file)
@@ -52,11 +52,8 @@ BOOL getversionmodule(wchar_t* _pwstModule,
         filename_VERSION_module = (char*)MALLOC(sizeof(char) * len);
         sprintf(filename_VERSION_module, FORMATVERSIONFILENAME, SciPath, pstModule);
         FREE(pstModule);
-        if (SciPath)
-        {
-            FREE(SciPath);
-            SciPath = NULL;
-        }
+        FREE(SciPath);
+        SciPath = NULL;
 
         if (FileExist(filename_VERSION_module))
         {
@@ -148,12 +145,16 @@ BOOL getversionmodule(wchar_t* _pwstModule,
                     *sci_version_minor = version_minor;
                     *sci_version_maintenance = version_maintenance;
                     *sci_version_revision = version_revision;
-                    wcscpy(_pwstSciVersionString, pwstSciVersionString);
                     if (pwstSciVersionString)
                     {
+                        wcscpy(_pwstSciVersionString, pwstSciVersionString);
                         FREE(pwstSciVersionString);
                         pwstSciVersionString = NULL;
                     }
+                    else
+                    {
+                        _pwstSciVersionString = NULL;
+                    }
                 }
                 else
                 {
@@ -177,11 +178,8 @@ BOOL getversionmodule(wchar_t* _pwstModule,
                 fprintf(stderr, _("Error: Not a valid version file %s (encoding not 'utf-8') Encoding '%s' found\n"), filename_VERSION_module, encoding);
             }
 
-            if (encoding)
-            {
-                FREE(encoding);
-                encoding = NULL;
-            }
+            FREE(encoding);
+            encoding = NULL;
             bOK = TRUE;
         }
         else
@@ -194,12 +192,8 @@ BOOL getversionmodule(wchar_t* _pwstModule,
             wcscpy(_pwstSciVersionString, L"");
             bOK = TRUE;
         }
-
-        if (filename_VERSION_module)
-        {
-            FREE(filename_VERSION_module);
-            filename_VERSION_module = NULL;
-        }
+        FREE(filename_VERSION_module);
+        filename_VERSION_module = NULL;
     }
     return bOK;
 }