From: James Turner Date: Tue, 23 Jul 2013 20:58:38 +0000 (+0100) Subject: Fix for #587, crash on break/continue. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a2e25e7940d2061c0a9298f4ef8347c6f174d42d;p=simgear.git Fix for #587, crash on break/continue. Look for use of break/continue outside of a loop context, and report a parser error instead of crashed. Thanks to Philosopher for the patch. --- diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c index fa2ddc22..8636fbb9 100644 --- a/simgear/nasal/codegen.c +++ b/simgear/nasal/codegen.c @@ -485,6 +485,11 @@ static int tokMatch(struct Token* a, struct Token* b) static void genBreakContinue(struct Parser* p, struct Token* t) { int levels = 1, loop = -1, bp, cp, i; + // http://code.google.com/p/flightgear-bugs/issues/detail?id=587 + // Make sure we are inside of a loop + if(p->cg->loopTop <= 0) + naParseError(p, "break/continue outside of a valid loop", t->line); + if(RIGHT(t)) { if(RIGHT(t)->type != TOK_SYMBOL) naParseError(p, "bad break/continue label", t->line);