Coverity: hdf5 module resource leaks fixed 70/18370/2
Dhruv Khattar [Sun, 17 Jul 2016 11:34:09 +0000 (16:34 +0530)]
Change-Id: If2521fb6c347791a2f598994ed4d5f73e92e59e2

scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp

index 43b5d1e..8d70374 100644 (file)
@@ -749,6 +749,7 @@ static bool import_integer(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piA
         }
         break;
         default:
+            FREE(piDims);
             return false;
     }
 
@@ -1483,6 +1484,8 @@ static bool import_struct(int* pvCtx, int _iDatasetId, int _iVarType, int _iItem
     }
 
     types::Struct* pStruct = new types::Struct(piDims[1], piDimsArray);
+    delete[] piDims;
+    delete[] piDimsArray;
 
     wchar_t* pwstName = NULL;
     for (int i = 0; i < (-2 + iItems); ++i)
@@ -1717,6 +1720,8 @@ static bool import_cell(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPo
     }
 
     types::Cell* pCell = new types::Cell(piDims[1], piDimsArray);
+    delete[] piDims;
+    delete[] piDimsArray;
     types::List* pList = new types::List();
     pList->set(0, types::Double::Empty());
 
index 263ae97..8890968 100644 (file)
@@ -615,6 +615,7 @@ static types::InternalType* import_struct(int dataset)
         {
             closeList6(dataset);
             freeStringMatrix(dfield, fields.data());
+            FREE(field);
             delete str;
             return nullptr;
         }
@@ -628,6 +629,7 @@ static types::InternalType* import_struct(int dataset)
         if (ret < 0)
         {
             freeStringMatrix(dfield, fields.data());
+            FREE(field);
             delete str;
             return nullptr;
         }
@@ -640,6 +642,7 @@ static types::InternalType* import_struct(int dataset)
             if (data < 0)
             {
                 freeStringMatrix(dfield, fields.data());
+                FREE(field);
                 delete str;
                 return nullptr;
             }
@@ -648,6 +651,7 @@ static types::InternalType* import_struct(int dataset)
             if (val == nullptr)
             {
                 freeStringMatrix(dfield, fields.data());
+                FREE(field);
                 delete str;
                 return nullptr;
             }
index 78e002d..fe20e38 100644 (file)
@@ -518,6 +518,7 @@ static int export_struct(int parent, const std::string& name, types::Struct* dat
             if (ret)
             {
                 delete fields;
+                FREE(cfield);
                 return -1;
             }
         }