commit: c9e719f5c3c85039fb2da01857e1fb1d8e18675f
parent 6c5d1e77490e585308e5193a7710b28b57344883
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 21 Apr 2024 15:02:17 +0200
cmd/test: return out of binop() on syntax error
Otherwise NULL gets passed to strcmp, caught by LLVM/Clang static analyzer.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/test.c b/cmd/test.c
@@ -314,7 +314,11 @@ binop(enum token n)
opnd1 = *t_wp;
op = nargc > 0 ? (--nargc, *++t_wp) : NULL;
- if((opnd2 = nargc > 0 ? (--nargc, *++t_wp) : NULL) == NULL) syntax(op, "argument expected");
+ if((opnd2 = nargc > 0 ? (--nargc, *++t_wp) : NULL) == NULL)
+ {
+ syntax(op, "argument expected");
+ return 0;
+ }
switch(n)
{