From 0bfc31a1e5ea03e9645e2f736d2fd3db355f68cc Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 29 Aug 2019 21:56:00 +0800 Subject: [PATCH] check for too many args to if (issue #561) --- eval.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 9e282900..bd676fa3 100644 --- a/eval.c +++ b/eval.c @@ -883,7 +883,9 @@ static sexp analyze_if (sexp ctx, sexp x, int depth) { sexp_gc_var3(test, pass, fail); sexp_gc_preserve3(ctx, test, pass, fail); if (! (sexp_pairp(sexp_cdr(x)) && sexp_pairp(sexp_cddr(x)))) { - res = sexp_compile_error(ctx, "bad if syntax", x); + res = sexp_compile_error(ctx, "not enough args to if", x); + } else if (sexp_pairp(sexp_cdddr(x)) && sexp_cdr(sexp_cdddr(x)) != SEXP_NULL) { + res = sexp_compile_error(ctx, "too many args to if", x); } else { test = analyze(ctx, sexp_cadr(x), depth, 0); pass = analyze(ctx, sexp_caddr(x), depth, 0);