]> git.saurik.com Git - bison.git/commit - data/glr.c
Rewrite GLR parser to catch more buffer overrun, storage exhaustion,
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2005 21:58:37 +0000 (21:58 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2005 21:58:37 +0000 (21:58 +0000)
commit63cb01d656aadba43f5ad2feb935bf32546002f2
treea6e0162aa7550f815867ab77bcb4f47cd401d71a
parent1c59e0a1212dd654259d9aca83838c77c8dab53e
Rewrite GLR parser to catch more buffer overrun, storage exhaustion,
and size overflow errors.
* data/glr.c: Include <stdio.h> etc. after user prolog, not before,
in case the user prolog sets feature-test macros like _GNU_SOURCE.
(YYSIZEMAX): New macro.
(yystpcpy): New function, taken from yacc.c.
(struct yyGLRStack.yyspaceLeft): Now size_t, not int.
(yyinitGLRStack, yyfreeGLRstack): Remove unnecessary forward decls,
so that we don't have to maintain their signatures.
(yyFail): Check for buffer overflow, by using vsnprintf rather
than vsprintf.  Allocate a bigger buffer if possible.
Report an error if buffer allocation fails.
(yyStackOverflow): New function.
(yyinitStateSet, yyinitGLRStack): Return a boolean indicating whether
the initialization was successful.  It might fail if storage was
exhausted.
(yyexpandGLRStack): Add more checks for storage allocation failure.
Use yyStackOverflow to report failures.
(yymarkStackDeleted, yyglrShift, yyglrShiftDefer, yydoAction):
(yysplitStack, yyprocessOneStack, yyparse, yypstack):
Don't assume stack number fits in int.
(yysplitStack): Check for storage allocation failure.
(yysplitStack, yyprocessOneStack): Add pure_formals, so that we
can print diagnostics on storage allocation failure.  All callers
changed.
(yyresolveValue): Use yybool for boolean.
(yyreportSyntaxError): Check for size-calculation overflow.
This code is taken from yacc.c.
(yyparse): Check for storage allocation errors when allocating
the initial stack.
ChangeLog
data/glr.c