Coverity #1098572, #1098442 fixed: Memory Leaks 51/18051/5
Dhruv Khattar [Wed, 6 Apr 2016 21:15:39 +0000 (02:15 +0530)]
Change-Id: Ic40c5873555cac942b2467dfe469c0a918106cfd

scilab/modules/xml/sci_gateway/cpp/sci_percent_c_i_XMLAttr.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlValidate.cpp

index 0641da2..3fbe54e 100644 (file)
@@ -105,6 +105,7 @@ int sci_percent_c_i_XMLAttr(char *fname, void* pvApiCtx)
             if (getAllocatedSingleString(pvApiCtx, nameaddr, &name) != 0)
             {
                 Scierror(999, _("%s: No more memory.\n"), fname);
+                freeAllocatedSingleString(prefix);
                 return 0;
             }
         }
index 685edfe..c7e3086 100644 (file)
@@ -91,12 +91,20 @@ int sci_xmlValidate(char *fname, void* pvApiCtx)
         {
             printError(&err, 0);
             Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+            if (path)
+            {
+                freeAllocatedMatrixOfString(row, col, path);
+            }
             return 0;
         }
 
         if (!isXMLValid(addr, pvApiCtx))
         {
             Scierror(999, gettext("%s: Wrong type for input argument #%d: A %s expected.\n"), fname, 1, "XMLValid");
+            if (path)
+            {
+                freeAllocatedMatrixOfString(row, col, path);
+            }
             return 0;
         }
 
@@ -105,6 +113,10 @@ int sci_xmlValidate(char *fname, void* pvApiCtx)
         if (!validation)
         {
             Scierror(999, gettext("%s: XML validation file does not exist.\n"), fname);
+            if (path)
+            {
+                freeAllocatedMatrixOfString(row, col, path);
+            }
             return 0;
         }
     }