From b98b4a05845f38c70cdf04eeaf20d631eeb939b8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 19 Mar 2014 13:27:05 +0000 Subject: [PATCH] don't leak on error --- Numeric/mathEvaluator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Numeric/mathEvaluator.cpp b/Numeric/mathEvaluator.cpp index f68fe7b463..8cb5ab0ea3 100644 --- a/Numeric/mathEvaluator.cpp +++ b/Numeric/mathEvaluator.cpp @@ -8,7 +8,7 @@ #if defined(HAVE_MATHEX) mathEvaluator::mathEvaluator(std::vector<std::string> &expressions, - std::vector<std::string> &variables) + std::vector<std::string> &variables) { _expressions.resize(expressions.size()); _variables.resize(variables.size(), 0.); @@ -30,7 +30,11 @@ mathEvaluator::mathEvaluator(std::vector<std::string> &expressions, error = true; } } - if(error) expressions.clear(); + if(error){ + for(unsigned int i = 0; i < _expressions.size(); i++) + delete(_expressions[i]); + expressions.clear(); + } } mathEvaluator::~mathEvaluator() @@ -50,7 +54,7 @@ bool mathEvaluator::eval(std::vector<double> &values, std::vector<double> &res) Msg::Error("Given %d results for %d expressions", res.size(), _expressions.size()); return false; } - + for(unsigned int i = 0; i < values.size(); i++) _variables[i] = values[i]; -- GitLab