From 2491d5f30573d9e5e72b3c7d2eac8788bbe69dd4 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 23 Mar 2017 23:42:41 +0100 Subject: fixed checks for missing left and right operands to binary operators * this resulted in assertions (crashes!) for harmless typos like "+23=" * a test case has been added --- src/expressions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/expressions.cpp b/src/expressions.cpp index 6c28080..7ccdd31 100644 --- a/src/expressions.cpp +++ b/src/expressions.cpp @@ -124,11 +124,11 @@ Expressions::calc(void) Operator op; tecoInt vleft; - if (operators.peek() != OP_NUMBER) + if (!operators.items() || operators.peek() != OP_NUMBER) throw Error("Missing right operand"); vright = pop_num(); op = pop_op(); - if (operators.peek() != OP_NUMBER) + if (!operators.items() || operators.peek() != OP_NUMBER) throw Error("Missing left operand"); vleft = pop_num(); -- cgit v1.2.3