memory leak fixed in insertion. 06/16506/3
Cedric Delamarre [Tue, 26 May 2015 08:29:01 +0000 (10:29 +0200)]
a=12;
b=12;
// extraction od b(1,1) was never deleted
a(1,1) = b(1,1);

// argument colon was never deleted
a(:) = b;

Change-Id: I29144af5cda06ce9c4f5c317405c787412a0d53c

scilab/modules/ast/src/cpp/ast/run_AssignExp.hpp

index 78739c3..0d9ab49 100644 (file)
@@ -252,15 +252,29 @@ namespace ast {
                             throw ast::ScilabError(os.str(), 999, pCall->getLocation());
                         }
 
+                        // prevent delete after extractFullMatrix
+                        // called in insertionCall when pITR is an ImplicitList
+                        pITR->IncreaseRef();
+
                         typed_list* currentArgs = GetArgumentList(pCall->getArgs());
                         pOut = insertionCall(e, currentArgs, pIT, pITR);
+
+                        pITR->DecreaseRef();
+
+                        // call killMe on all arguments
+                        cleanOut(*currentArgs);
+                        delete currentArgs;
+
+                        // insertion have done, call killMe on pITR
+                        pITR->killMe();
+
                         if (pOut == NULL)
                         {
                             std::wostringstream os;
                             os << _W("Submatrix incorrectly defined.\n");
                             throw ast::ScilabError(os.str(), 999, e.getLocation());
                         }
-                        delete currentArgs;
+
 
                         //update variable with new value
                         if (pOut != pIT)