mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
Avoid undefined behavior that accessed just before the start of an array.
* src/reader.c (packgram): Prepend a new sentinel before ritem. * src/lalr.c (build_relations): Rely on new sentinel. * src/gram.c (gram_free): Adjust to new sentinel.
This commit is contained in:
@@ -418,7 +418,11 @@ packgram (void)
|
||||
rule_number ruleno = 0;
|
||||
symbol_list *p = grammar;
|
||||
|
||||
ritem = xnmalloc (nritems, sizeof *ritem);
|
||||
ritem = xnmalloc (nritems + 1, sizeof *ritem);
|
||||
|
||||
/* This sentinel is used by build_relations in gram.c. */
|
||||
*ritem++ = 0;
|
||||
|
||||
rules = xnmalloc (nrules, sizeof *rules);
|
||||
|
||||
while (p)
|
||||
|
||||
Reference in New Issue
Block a user