[PATCH v4 23/25] return an error if too few args

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 evaluate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/evaluate.c b/evaluate.c
index 46ea10ed8..0cec215ba 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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",
-- 
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux