diff options
author | Steve Bennett <steveb@workware.net.au> | 2017-08-05 12:33:13 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2017-08-07 20:36:27 +1000 |
commit | 028dd5dd2f58456e27cd6c54b1539fc16406bc9a (patch) | |
tree | f57eed4b5be14a97e38031154468bdeca3e07414 /jim.c | |
parent | 59f01cb74b4b6f8c32cc4083735050b233ad4380 (diff) | |
download | jimtcl-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.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 */ |