mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
named references: fix double free.
In `rhs[name]: "a" | "b"', do not free "name" twice.
Reported by Tys Lefering.
<http://lists.gnu.org/archive/html/bug-bison/2010-06/msg00002.html>
* src/named-ref.h, src/named-ref.c (named_ref_copy): New.
* src/parse-gram.y (current_lhs): Rename as...
(current_lhs_symbol): this.
(current_lhs): New function. Use it to free the current lhs
named reference.
* src/reader.c: Bind lhs to a copy of the current named reference.
* src/symlist.c: Rely on free (0) being valid.
* tests/named-refs.at: Test this.
(cherry picked from commit 8f462efe92)
Conflicts:
src/parse-gram.y
This commit is contained in:
@@ -472,6 +472,19 @@ AT_CLEANUP
|
||||
|
||||
#######################################################################
|
||||
|
||||
# Bison used to free twice the named ref for "a", since a single copy
|
||||
# was used in two rules.
|
||||
AT_SETUP([Factored LHS])
|
||||
AT_DATA_GRAMMAR([test.y],
|
||||
[[
|
||||
%%
|
||||
start[a]: "foo" | "bar";
|
||||
]])
|
||||
AT_BISON_CHECK([-o test.c test.y])
|
||||
AT_CLEANUP
|
||||
|
||||
#######################################################################
|
||||
|
||||
AT_SETUP([Unresolved references])
|
||||
AT_DATA_GRAMMAR([test.y],
|
||||
[[
|
||||
|
||||
Reference in New Issue
Block a user