From: ThorstenB Date: Sat, 29 Oct 2011 19:20:46 +0000 (+0200) Subject: #453: Using = as Nasal function argument crashes FG X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aa0e3e3c9fd6bf174493e4ab1e3c292fc924a4f0;p=simgear.git #453: Using = as Nasal function argument crashes FG Keep Nasal parser from crashing when "=" function misses a left-hand element, i.e. when parsing "sin(=)". (Or do people writing such terrible syntax deserve a crash? ;-) ). --- diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c index d1c05ef6..059c1144 100644 --- a/simgear/nasal/codegen.c +++ b/simgear/nasal/codegen.c @@ -536,6 +536,9 @@ static void genAssign(struct Parser* p, struct Token* t) { struct Token *lv = LEFT(t), *rv = RIGHT(t); int len, dummy, var=0; + if (!lv) + naParseError(p, "bad assignment, missing variable", t->line); + else if(parListLen(lv) || (lv->type == TOK_VAR && parListLen(RIGHT(lv)))) { if(lv->type == TOK_VAR) { lv = RIGHT(lv); var = 1; } len = parListLen(lv);