From 3daaa7843ec07f357d93d6dfd9524273a165419c Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 11 May 2014 09:43:41 +1000 Subject: [PATCH] parsergen: Don't look beyond the bottom of stack... If the stack is empty, looking beyond for whether newlines are permitted is dangerous. 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 37dcf7e..2cfcb45 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2530,7 +2530,7 @@ at the start of a production. // will fail). } if (p.next.sym == TK_newline) { - if (! p.stack[p.tos-1].newline_permitted) { + if (!p.tos || ! p.stack[p.tos-1].newline_permitted) { free(tk); tk = NULL; continue; -- 2.43.0