[Optimization] leaks fixed 74/20274/2
Cedric Delamarre [Mon, 16 Jul 2018 12:14:44 +0000 (14:14 +0200)]
Change-Id: I28c60b78a4158e32bc67468a358d0cb9bb92189c

scilab/modules/optimization/sci_gateway/cpp/sci_fsolve.cpp
scilab/modules/optimization/src/cpp/optimizationfunctions.cpp

index 7d8b23c..0a6a737 100644 (file)
@@ -307,7 +307,8 @@ types::Function::ReturnValue sci_fsolve(types::typed_list &in, int _iRetCount, t
     if (iInfo == -1)
     {
         char* pstrMsg = wide_string_to_UTF8(ConfigVariable::getLastErrorMessage().c_str());
-        Scierror(999, "fsolve: %s\n",pstrMsg);
+        Scierror(999, "fsolve: %s\n", pstrMsg);
+        delete pDblV;
         return types::Function::Error;
     }
 
index bdffd99..bc8e55d 100644 (file)
@@ -395,7 +395,10 @@ void OptimizationFunctions::callCostfMacro(int *ind, int *n, double *x, double *
         {
             m_OptimArgs[i]->DecreaseRef();
         }
-
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblInd->DecreaseRef();
+        pDblInd->killMe();
         throw ie;
     }
 
@@ -409,6 +412,10 @@ void OptimizationFunctions::callCostfMacro(int *ind, int *n, double *x, double *
         char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
         sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
         FREE(pstrName);
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblInd->DecreaseRef();
+        pDblInd->killMe();
         throw ast::InternalError(errorMsg);
     }
 
@@ -553,7 +560,8 @@ void OptimizationFunctions::callFsolveFctMacro(int *n, double *x, double *v, int
         {
             m_fsolveFctArgs[i]->DecreaseRef();
         }
-
+        pDblX->DecreaseRef();
+        pDblX->killMe();
         throw ie;
     }
 
@@ -567,6 +575,8 @@ void OptimizationFunctions::callFsolveFctMacro(int *n, double *x, double *v, int
         char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
         sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
         FREE(pstrName);
+        pDblX->DecreaseRef();
+        pDblX->killMe();
         throw ast::InternalError(errorMsg);
     }
 
@@ -642,7 +652,8 @@ void OptimizationFunctions::callFsolveJacMacro(int *n, double *x, double *v, dou
         {
             m_fsolveJacArgs[i]->DecreaseRef();
         }
-
+        pDblX->DecreaseRef();
+        pDblX->killMe();
         throw ie;
     }
 
@@ -656,6 +667,8 @@ void OptimizationFunctions::callFsolveJacMacro(int *n, double *x, double *v, dou
         char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
         sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
         FREE(pstrName);
+        pDblX->DecreaseRef();
+        pDblX->killMe();
         throw ast::InternalError(errorMsg);
     }
 
@@ -736,7 +749,10 @@ void OptimizationFunctions::callLsqrsolveFctMacro(int *m, int *n, double *x, dou
         {
             m_fsolveFctArgs[i]->DecreaseRef();
         }
-
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblM->DecreaseRef();
+        pDblM->killMe();
         throw ie;
     }
 
@@ -750,6 +766,10 @@ void OptimizationFunctions::callLsqrsolveFctMacro(int *m, int *n, double *x, dou
         char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
         sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
         FREE(pstrName);
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblM->DecreaseRef();
+        pDblM->killMe();
         throw ast::InternalError(errorMsg);
     }
 
@@ -833,7 +853,10 @@ void OptimizationFunctions::callLsqrsolveJacMacro(int *m, int *n, double *x, dou
         {
             m_fsolveJacArgs[i]->DecreaseRef();
         }
-
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblM->DecreaseRef();
+        pDblM->killMe();
         throw ie;
     }
 
@@ -847,6 +870,10 @@ void OptimizationFunctions::callLsqrsolveJacMacro(int *m, int *n, double *x, dou
         char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
         sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
         FREE(pstrName);
+        pDblX->DecreaseRef();
+        pDblX->killMe();
+        pDblM->DecreaseRef();
+        pDblM->killMe();
         throw ast::InternalError(errorMsg);
     }