Fix some errors reported by scan-build in the spreadsheet functions 39/9039/2
Sylvestre Ledru [Tue, 18 Sep 2012 08:59:04 +0000 (10:59 +0200)]
Change-Id: Iffa16490c7799c1e51afc69047aba0537e989ed0

scilab/modules/spreadsheet/sci_gateway/cpp/sci_csvRead.cpp
scilab/modules/spreadsheet/sci_gateway/cpp/sci_csvWrite.cpp
scilab/modules/spreadsheet/src/cpp/csvRead.c

index 13fb433..bd1b868 100644 (file)
@@ -180,7 +180,11 @@ int sci_csvRead(char *fname)
     {
         int iErr = 0;
         conversion = csv_getArgumentAsStringWithEmptyManagement(pvApiCtx, 4, fname, getCsvDefaultConversion(), &iErr);
-        if (iErr) return 0;
+        if (iErr)
+        {
+            FREE(regexp);
+            return 0;
+        }
         if (!((strcmp(conversion, CONVTOSTR) == 0) || (strcmp(conversion, CONVTODOUBLE) == 0)))
         {
             if (regexp)
index de07b22..74be420 100644 (file)
@@ -173,6 +173,7 @@ int sci_csvWrite(char *fname)
         {
             //invalid value
             Scierror(999, _("%s: Wrong value for input argument #%d: '%s' or '%s' expected.\n"), "write_csv", 4, ".", ",");
+            FREE(precisionFormat);
             return 1;
         }
     }
index 8d9405d..7a04cff 100644 (file)
@@ -260,6 +260,7 @@ csvResult* csvTextScan(const char **lines, int numberOfLines, const char *separa
             result->pstrComments = NULL;
             result->nbComments = 0;
         }
+        FREE(cleanedLines);
         return result;
     }
     else
@@ -286,6 +287,10 @@ csvResult* csvTextScan(const char **lines, int numberOfLines, const char *separa
             result->pstrComments = NULL;
             result->nbComments = 0;
         }
+        else
+        {
+            FREE(cellsStrings);
+        }
     }
     else
     {