]> ocean-lang.org Git - ocean/commitdiff
parsergen: guard against tos going negative.
authorNeilBrown <neil@brown.name>
Wed, 10 Mar 2021 00:58:08 +0000 (11:58 +1100)
committerNeilBrown <neil@brown.name>
Wed, 10 Mar 2021 01:00:28 +0000 (12:00 +1100)
Don't continue the parse loop if tos hits zero.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/parsergen.mdc

index da9335ed0df1794fe49c35030272e333956259a3..a913cb912c77cf5a977e835b4bd1ec8ac212929b 100644 (file)
@@ -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)