From: James Turner Date: Tue, 23 Jul 2013 08:43:08 +0000 (+0100) Subject: Bug 737, crash parsing default args. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3cb2241b1dbaca4e074684ce1e2f4abf400d0593;p=simgear.git Bug 737, crash parsing default args. Reject function evaluation explicitly when building default arguments. --- 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) {