From 3cb2241b1dbaca4e074684ce1e2f4abf400d0593 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 23 Jul 2013 09:43:08 +0100 Subject: [PATCH] Bug 737, crash parsing default args. Reject function evaluation explicitly when building default arguments. --- simgear/nasal/codegen.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c index 059c1144..d8b701b6 100644 --- a/simgear/nasal/codegen.c +++ b/simgear/nasal/codegen.c @@ -147,7 +147,15 @@ static void genEqOp(int op, struct Parser* p, struct Token* t) static int defArg(struct Parser* p, struct Token* t) { - if(t->type == TOK_LPAR) return defArg(p, RIGHT(t)); + if(t->type == TOK_LPAR) { + // http://code.google.com/p/flightgear-bugs/issues/detail?id=737 + // TOK_LPAR can mean multi-value assignment or function call, + // disambigaute by checking the rule of the token + if (t->rule == PREC_SUFFIX) + naParseError(p, "default arguments cannot be function calls", t->line); + return defArg(p, RIGHT(t)); + } + if(t->type == TOK_MINUS && RIGHT(t) && RIGHT(t)->type == TOK_LITERAL && !RIGHT(t)->str) { -- 2.39.5