mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 00:03:03 +00:00
glr2.cc: fix memory leak
* data/skeletons/glr2.cc (glr_stack_item::setState): Free the previous state before installing the new one.
This commit is contained in:
@@ -1374,10 +1374,10 @@ public:
|
|||||||
~glr_stack_item ()
|
~glr_stack_item ()
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
check_ ();]])[
|
check_ ();]])[
|
||||||
if (is_state())
|
if (is_state ())
|
||||||
getState().~glr_state();
|
getState ().~glr_state ();
|
||||||
else
|
else
|
||||||
getOption().~semantic_option();
|
getOption ().~semantic_option ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setState (const glr_state &state)
|
void setState (const glr_state &state)
|
||||||
@@ -1386,12 +1386,12 @@ public:
|
|||||||
state.check_ ();]])[
|
state.check_ ();]])[
|
||||||
if (this != state.asItem ())
|
if (this != state.asItem ())
|
||||||
{
|
{
|
||||||
is_state_ = true;
|
if (is_state_)
|
||||||
// FIXME: What about the previous content? Shouldn't it be
|
getState ().~glr_state ();
|
||||||
// freed? It might be useful to have an explicit "void" state
|
else
|
||||||
// when this item is in unused state (in the list of free
|
getOption ().~semantic_option ();
|
||||||
// items), when parse.assert is set.
|
|
||||||
new (&raw_) glr_state (state);
|
new (&raw_) glr_state (state);
|
||||||
|
is_state_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user