From: NeilBrown Date: Wed, 10 Mar 2021 00:58:08 +0000 (+1100) Subject: parsergen: guard against tos going negative. X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=a6a01462706cb96aaea89188bc66ea34a7899385 parsergen: guard against tos going negative. Don't continue the parse loop if tos hits zero. Signed-off-by: NeilBrown --- 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)