diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-30 23:01:02 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-31 02:32:59 +0200 |
| commit | 3cf996e8479929b8d25a845f43fde2e5d6035334 (patch) | |
| tree | 592c0dcb0d9056f2c2f38952cba8d21ff8b5bc9c /evaluate.c | |
| parent | 826ff0b7e91d2414eae15030238b74a02c48e931 (diff) | |
| download | sparse-dev-3cf996e8479929b8d25a845f43fde2e5d6035334.tar.gz | |
return an error if too few args
In evaluate_call(), argumenst are evaluated an a diagnostic
is emitted if the number of args is not what is expected.
Good.
However, the processing continues nevertheless.
If too much args were given, this doesn't matter much
but if too few are given we need to check a bit everywhere
for possible NULL args.
Avoid this by returning early an error if there was too few
arguments.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
| -rw-r--r-- | evaluate.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -3019,10 +3019,12 @@ static struct symbol *evaluate_call(struct expression *expr) return NULL; args = expression_list_size(expr->args); fnargs = symbol_list_size(ctype->arguments); - if (args < fnargs) + if (args < fnargs) { expression_error(expr, "not enough arguments for function %s", show_ident(sym->ident)); + return NULL; + } if (args > fnargs && !ctype->variadic) expression_error(expr, "too many arguments for function %s", |
