Fix some errors found by coverity: 31/12731/2
Sylvestre Ledru [Sat, 28 Sep 2013 11:00:28 +0000 (13:00 +0200)]
* Remove memory leaks (CID 1098699, 1098702, 1098706, 1098708, 1098711)

Change-Id: I03905bb40c5956bba2fa1f074cfaab700d0e9cf1

scilab/modules/spreadsheet/sci_gateway/c/sci_csvRead.c

index 7048112..9d8de54 100644 (file)
@@ -251,6 +251,11 @@ int sci_csvRead(char *fname, unsigned long fname_len)
                 freeArrayOfString(toreplace, nbElementsToReplace * 2);
                 toreplace = NULL;
             }
+            if (decimal)
+            {
+                FREE(decimal);
+                decimal = NULL;
+            }
             return 0;
         }
     }
@@ -285,6 +290,11 @@ int sci_csvRead(char *fname, unsigned long fname_len)
                 FREE(decimal);
                 decimal = NULL;
             }
+            if (separator)
+            {
+                FREE(separator);
+                separator = NULL;
+            }
             return 0;
         }
     }
@@ -330,6 +340,11 @@ int sci_csvRead(char *fname, unsigned long fname_len)
             FREE(decimal);
             decimal = NULL;
         }
+        if (filename)
+        {
+            FREE(filename);
+            filename = NULL;
+        }
         return 0;
     }
 
@@ -514,6 +529,7 @@ int sci_csvRead(char *fname, unsigned long fname_len)
                         }
                         LhsVar(2) = Rhs + 2;
                     }
+                    FREE(result);
                     PutLhsVar();
                 }
             }
@@ -556,6 +572,11 @@ int sci_csvRead(char *fname, unsigned long fname_len)
         Scierror(999, _("%s: Memory allocation error.\n"), fname);
     }
     releaseObjects(result, filename, conversion);
+    if (iRange)
+    {
+        FREE(iRange);
+        iRange = NULL;
+    }
 
     return 0;
 }
@@ -569,4 +590,4 @@ static void releaseObjects(csvResult *result, char* filename, char* conversion)
 
     FREE(conversion);
     conversion = NULL;
-}
\ No newline at end of file
+}