aboutsummaryrefslogtreecommitdiff
path: root/jim.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2017-08-05 12:33:13 +1000
committerSteve Bennett <steveb@workware.net.au>2017-08-07 20:36:27 +1000
commit028dd5dd2f58456e27cd6c54b1539fc16406bc9a (patch)
treef57eed4b5be14a97e38031154468bdeca3e07414 /jim.c
parent59f01cb74b4b6f8c32cc4083735050b233ad4380 (diff)
downloadjimtcl-028dd5dd2f58456e27cd6c54b1539fc16406bc9a.zip
jimtcl-028dd5dd2f58456e27cd6c54b1539fc16406bc9a.tar.gz
jimtcl-028dd5dd2f58456e27cd6c54b1539fc16406bc9a.tar.bz2
expr: Check for missing operand to operator
Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r--jim.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/jim.c b/jim.c
index e69d4c0..cf9b758 100644
--- a/jim.c
+++ b/jim.c
@@ -8899,12 +8899,26 @@ noargs:
if (op->arity >= 3) {
node->ternary = Jim_StackPop(&builder->stack);
+ if (node->ternary == NULL) {
+ goto missingoperand;
+ }
}
if (op->arity >= 2) {
node->right = Jim_StackPop(&builder->stack);
+ if (node->right == NULL) {
+ printf("missing right term to operator %s\n", op->name);
+ goto missingoperand;
+ }
}
if (op->arity >= 1) {
node->left = Jim_StackPop(&builder->stack);
+ if (node->left == NULL) {
+missingoperand:
+ Jim_SetResultFormatted(interp, "missing operand to %s in expression: \"%#s\"", op->name, builder->exprObjPtr);
+ builder->next--;
+ return JIM_ERR;
+
+ }
}
/* Now push the node */