From: Paul Eggert Date: Wed, 20 Jul 2005 21:43:32 +0000 (+0000) Subject: (yyreturn): Don't pop stack if yyinitStateSet failed, X-Git-Tag: BISON-2_1~66 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/6fdb09caac6ee472315f0cf849cb2e105d931266 (yyreturn): Don't pop stack if yyinitStateSet failed, as the stack isn't valid in that case. --- diff --git a/data/glr.c b/data/glr.c index 578ad116..219dd3f5 100644 --- a/data/glr.c +++ b/data/glr.c @@ -2107,17 +2107,21 @@ b4_syncline([@oline@], [@ofile@])])dnl yytoken, yylvalp]b4_location_if([, yyllocp])[); /* Now pop stack until empty, destroying its entries as we go. */ - while (yystack.yytops.yystates[0] != NULL) - { - yyGLRState *yys = yystack.yytops.yystates[0]; -]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ - yydestruct ("Error: popping", - yystos[yys->yylrState], - &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[); - yystack.yytops.yystates[0] = yys->yypred; - yystack.yynextFree -= 1; - yystack.yyspaceLeft += 1; - } + { + yyGLRState** yystates = yystack.yytops.yystates; + if (yystates) + while (yystates[0]) + { + yyGLRState *yys = yystates[0]; +]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] +)[ yydestruct ("Error: popping", + yystos[yys->yylrState], + &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[); + yystates[0] = yys->yypred; + yystack.yynextFree -= 1; + yystack.yyspaceLeft += 1; + } + } yyfreeGLRStack (&yystack); return yyresult;