invalid read and leaks fixed 56/20456/1
Cedric Delamarre [Thu, 9 Aug 2018 08:43:24 +0000 (10:43 +0200)]
Change-Id: I1ad05c0840a2ecd75cbd67bbfd38c6915c62444d

scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/ast/src/cpp/types/arrayof.cpp
scilab/modules/ast/src/cpp/types/macro.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp

index 319f225..d8032d1 100644 (file)
@@ -2352,7 +2352,6 @@ ast::Exp* callTyper(ast::Exp* _tree, std::wstring _msg)
         unsigned char* astbin = s->serialize();
         //call ocamlpro typer
         //char *newast = ocamlpro_typer(astbin);
-        //free(astbin);
 
         //for debug
         newast = astbin;
@@ -2372,7 +2371,6 @@ ast::Exp* callTyper(ast::Exp* _tree, std::wstring _msg)
 
         //call ocamlpro typer
         //char *newast = ocamlpro_typer(astbin);
-        //free(astbin);
 
         //for debug
         newast = astbin;
index 3a3f29a..134d409 100644 (file)
@@ -128,6 +128,10 @@ ArrayOf<T>* ArrayOf<T>::insert(typed_list* _pArgs, InternalType* _pSource)
     //only scalar can be used to ".=" operation
     if (iSeqCount != pSource->getSize() && pSource->isScalar() == false)
     {
+        delete[] piCountDim;
+        delete[] piMaxDim;
+        //free pArg content
+        cleanIndexesArguments(_pArgs, &pArg);
         return NULL;
     }
 
@@ -180,6 +184,10 @@ ArrayOf<T>* ArrayOf<T>::insert(typed_list* _pArgs, InternalType* _pSource)
     {
         if (indexes.size() == 0)
         {
+            delete[] piCountDim;
+            delete[] piMaxDim;
+            //free pArg content
+            cleanIndexesArguments(_pArgs, &pArg);
             return this;
         }
 
@@ -189,6 +197,10 @@ ArrayOf<T>* ArrayOf<T>::insert(typed_list* _pArgs, InternalType* _pSource)
         //only scalar can be used to ".=" operation
         if (sizeIn != 1 && count != sizeIn)
         {
+            delete[] piCountDim;
+            delete[] piMaxDim;
+            //free pArg content
+            cleanIndexesArguments(_pArgs, &pArg);
             return NULL;
         }
 
@@ -257,6 +269,10 @@ ArrayOf<T>* ArrayOf<T>::insert(typed_list* _pArgs, InternalType* _pSource)
 
             if (status)
             {
+                delete[] piCountDim;
+                delete[] piMaxDim;
+                //free pArg content
+                cleanIndexesArguments(_pArgs, &pArg);
                 return this;
             }
 
index 6db7057..bf81b6b 100644 (file)
@@ -527,16 +527,10 @@ bool Macro::operator==(const InternalType& it)
     unsigned int macroSize = *((unsigned int*)macroSerial);
     if (oldSize != macroSize)
     {
-        free(oldSerial);
-        free(macroSerial);
         return false;
     }
 
     bool ret = (memcmp(oldSerial, macroSerial, oldSize) == 0);
-
-    free(oldSerial);
-    free(macroSerial);
-
     return ret;
 }
 
index fe20e38..3f5997b 100644 (file)
@@ -894,7 +894,6 @@ static int export_macro(int parent, const std::string& name, types::Macro* data)
     dims[0] = 1;
     dims[1] = size;
     writeIntegerMatrix6(dset, "body", H5T_NATIVE_UINT8, "u8", 2, dims, serialAst);
-    free(serialAst);
 
     closeList6(dset);
     return dset;