From a6a01462706cb96aaea89188bc66ea34a7899385 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 10 Mar 2021 11:58:08 +1100 Subject: [PATCH] parsergen: guard against tos going negative. Don't continue the parse loop if tos hits zero. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index da9335e..a913cb9 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2990,7 +2990,7 @@ checks if a given token is in any of these look-ahead sets. void *ret = NULL; shift(&p, TK_eof, 0, 1, NULL, states); - while (!accepted) { + while (!accepted && p.tos > 0) { struct token *err_tk; struct frame *tos = &p.stack[p.tos-1]; if (!tk) -- 2.43.0