]> ocean-lang.org Git - ocean/commitdiff
parsergen: Don't look beyond the bottom of stack...
authorNeilBrown <neilb@suse.de>
Sat, 10 May 2014 23:43:41 +0000 (09:43 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 05:40:03 +0000 (15:40 +1000)
If the stack is empty, looking beyond for whether newlines are
permitted is dangerous.

Signed-off-by: NeilBrown <neilb@suse.de>
csrc/parsergen.mdc

index 37dcf7eb12a1348e6a07378f2cbf67cf7fa78ffc..2cfcb45491d6f91f54e3dab24124c076c95e40b1 100644 (file)
@@ -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;