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.
This commit is contained in:
James Turner 2013-07-23 21:58:38 +01:00
parent d45a0161cf
commit a2e25e7940

View File

@ -485,6 +485,11 @@ static int tokMatch(struct Token* a, struct Token* b)
static void genBreakContinue(struct Parser* p, struct Token* t) static void genBreakContinue(struct Parser* p, struct Token* t)
{ {
int levels = 1, loop = -1, bp, cp, i; 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)) {
if(RIGHT(t)->type != TOK_SYMBOL) if(RIGHT(t)->type != TOK_SYMBOL)
naParseError(p, "bad break/continue label", t->line); naParseError(p, "bad break/continue label", t->line);