Memory Leaks detected by cppcheck #5 52/19852/4
Nimish Kapoor [Wed, 14 Mar 2018 11:55:14 +0000 (16:55 +0530)]
Change-Id: Ia01e1f9844ba7b9fdd1dc676a763b2a856b3f3f7

scilab/modules/ast/src/cpp/ast/visitor_common.cpp

index 6379d14..468e179 100644 (file)
@@ -469,7 +469,7 @@ types::InternalType* AddElementToVariable(types::InternalType* _poDest, types::I
                 break;
         }
 
-        if(poResult && isNew)
+        if (poResult && isNew)
         {
             poResult->killMe();
         }
@@ -541,7 +541,7 @@ types::InternalType* AddElementToVariable(types::InternalType* _poDest, types::I
                 break;
             default:
             {
-                if(poResult && isNew)
+                if (poResult && isNew)
                 {
                     poResult->killMe();
                 }
@@ -1867,7 +1867,6 @@ types::InternalType* insertionCall(const ast::Exp& e, types::typed_list* _pArgs,
         if ((*_pArgs)[0]->isString())
         {
             types::String *pS = (*_pArgs)[0]->getAs<types::String>();
-            types::Struct* pStr = new types::Struct(1, 1);
 
             if (_pArgs->size() != 1 || pS->isScalar() == false)
             {
@@ -1881,6 +1880,7 @@ types::InternalType* insertionCall(const ast::Exp& e, types::typed_list* _pArgs,
                 throw ast::InternalError(os.str(), 999, e.getLocation());
             }
 
+            types::Struct* pStr = new types::Struct(1, 1);
             pStr->addField(pS->get(0));
             pStr->get(0)->set(pS->get(0), _pInsert);
             pOut = pStr;