differential_equations: fix dasrt/dassl memleaks
[scilab.git] / scilab / modules / differential_equations / sci_gateway / cpp / sci_dassl.cpp
index e06787b..04c95a6 100644 (file)
@@ -702,6 +702,10 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
 
         if (iret == 1) // error
         {
+            for (types::InternalType* pIT : lpDblOut)
+            {
+                pIT->killMe();
+            }
             lpDblOut.clear();
             DifferentialEquation::removeDifferentialEquationFunctions();
             FREE(pdYdotData);
@@ -721,7 +725,7 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
             if (bCatch)
             {
                 wchar_t szError[bsiz];
-                os_swprintf(szError, bsiz, _W("%s: An error occured in '%s' subroutine.\n").c_str(), "dassl", "dassl");
+                os_swprintf(szError, bsiz, _W("%ls: An error occurred in '%ls' subroutine.\n").c_str(), L"dassl", L"dassl");
                 os << szError;
                 throw ast::InternalError(os.str());
             }
@@ -766,6 +770,7 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
     {
         int pos = i * rowsOut;
         C2F(dcopy)(&rowsOut, lpDblOut.front()->get(), &one, pDblOut->get() + pos, &one);
+        lpDblOut.front()->killMe();
         lpDblOut.pop_front();
     }
     out.push_back(pDblOut);