From: NeilBrown Date: Sat, 10 May 2014 23:43:41 +0000 (+1000) Subject: parsergen: Don't look beyond the bottom of stack... X-Git-Tag: workingparser~45 X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=3daaa7843ec07f357d93d6dfd9524273a165419c 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 --- 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;