fix memleak displayed by Inspector::displayMemleak() 75/15375/3
Cedric Delamarre [Tue, 14 Oct 2014 13:47:46 +0000 (15:47 +0200)]
Change-Id: I82ad24be10bf6e1648cda7273fb0fb65cdd8dad6

scilab/modules/ast/includes/analysis/AnalysisVisitor.hxx
scilab/modules/ast/includes/ast/dummyvisitor.hxx
scilab/modules/ast/includes/ast/serializervisitor.hxx
scilab/modules/ast/includes/exps/selectexp.hxx
scilab/modules/ast/src/cpp/ast/debugvisitor.cpp
scilab/modules/ast/src/cpp/ast/printvisitor.cpp
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/types/implicitlist.cpp
scilab/modules/ast/src/cpp/types/macro.cpp

index 30b582f..3efc710 100644 (file)
@@ -492,6 +492,8 @@ private:
         {
             (*i)->accept(*this);
         }
+        delete cases;
+
         e.getDefaultCase()->accept(*this);
     }
 
index 44f19f1..a8d2cd2 100644 (file)
@@ -207,6 +207,7 @@ protected:
         {
             (*it)->accept(*this);
         }
+        delete cases;
 
         if (e.getDefaultCase() != NULL)
         {
index d527410..551940e 100644 (file)
@@ -462,8 +462,9 @@ private :
         }
         add_exp(e.getSelect());
 
-        add_uint32((unsigned int)e.getCases()->size());
         exps_t* cases = e.getCases();
+        add_uint32((unsigned int)cases->size());
+
         for (exps_t::iterator it = cases->begin(), itEnd = cases->end(); it !=  itEnd ; ++it)
         {
             const CaseExp *ce = (*it)->getAs<CaseExp>();
@@ -472,6 +473,8 @@ private :
             add_exp(ce->getTest());
             add_exps(ce->getBody()->getAs<SeqExp>()->getExps());
         }
+
+        delete cases;
     }
     void visit(const CellExp& e)  /* done */
     {
index 2147b2b..2b727f7 100644 (file)
@@ -122,7 +122,7 @@ public :
 
         for (; it != itEnd ; ++it)
         {
-            cases->push_back((*it)->clone());
+            cases->push_back(*it);
         }
 
         return cases;
index f1321ac..080870f 100644 (file)
@@ -307,6 +307,7 @@ void DebugVisitor::visit (const SelectExp &e)
     {
         (*it)->accept(*this);
     }
+    delete cases;
 
     if (e.getDefaultCase() != NULL)
     {
index 91a7492..469ce86 100644 (file)
@@ -480,6 +480,8 @@ void PrintVisitor::visit (const SelectExp &e)
     {
         (*it)->getOriginal()->accept(*this);
     }
+    delete cases;
+
     if (e.hasDefault())
     {
         this->apply_indent();
index 4ca16f0..45911ff 100644 (file)
@@ -610,6 +610,8 @@ void RunVisitorT<T>::visitprivate(const SelectExp &e)
                 }
             }
         }
+
+        delete cases;
     }
 
     if (bCase == false && e.getDefaultCase() != NULL)
@@ -1005,7 +1007,7 @@ void RunVisitorT<T>::visitprivate(const FunctionDec & e)
     }
 
     types::Macro *pMacro = new types::Macro(e.getSymbol().getName(), *pVarList, *pRetList,
-                                            const_cast<SeqExp&>(static_cast<const SeqExp&>(e.getBody())), L"script");
+                                            *const_cast<SeqExp&>(static_cast<const SeqExp&>(e.getBody())).clone(), L"script");
     pMacro->setFirstLine(e.getLocation().first_line);
 
     bool bEquals = false;
index ff8d547..225b8d4 100644 (file)
@@ -369,8 +369,10 @@ bool ImplicitList::toString(std::wostringstream& ostr)
 {
     if (isComputable())
     {
-        bool ret = extractFullMatrix()->toString(ostr);
+        types::InternalType* pIT = extractFullMatrix();
+        bool ret = pIT->toString(ostr);
         scilabWriteW(ostr.str().c_str());
+        delete pIT;
         return ret;
     }
     else
index 3517e29..8aa50a7 100644 (file)
@@ -54,7 +54,7 @@ Macro::Macro(const std::wstring& _stName, std::list<symbol::Variable*>& _inputAr
 
 Macro::~Macro()
 {
-    //delete m_body;
+    delete m_body;
     m_pDblArgIn->DecreaseRef();
     m_pDblArgIn->killMe();
     m_pDblArgOut->DecreaseRef();