From aa0e3e3c9fd6bf174493e4ab1e3c292fc924a4f0 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 29 Oct 2011 21:20:46 +0200 Subject: [PATCH] #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? ;-) ). --- simgear/nasal/codegen.c | 3 +++ 1 file changed, 3 insertions(+) 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);