Commit a3a292bd authored by yannick legoc's avatar yannick legoc

Do not allow multiple expressions (separated by ,)

parent 86e8db71
......@@ -190,6 +190,11 @@ void MathExpression::init() {
try {
// Evaluates the expression, that can generate errors.
_parser->Eval();
// Do not accept multiple expressions (separated with ,)
if (_parser->GetNumResults() > 1) {
throw ParserError("Only single expressions are allowed.");
}
}
catch (mu::Parser::exception_type &e) {
throw ParserError(e.GetMsg());
......@@ -304,7 +309,14 @@ double MathExpression::evaluateValue() {
checkValue(true);
// Evaluates the expression.
return _parser->Eval();
double value = _parser->Eval();
// Do not accept multiple expressions (separated with ,)
if (_parser->GetNumResults() > 1) {
throw ParserError("Only single expressions are allowed.");
}
return value;
}
catch (const mu::Parser::exception_type & e) {
throw ParserError(e.GetMsg());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment