When iterating a hash_map, be careful not to delete i->first

before doing ++i to avoid memory issues.

* src/tgba/taatgba.cc, src/tgba/taatgba.hh,
src/tgba/tgbaexplicit.cc, src/tgba/tgbaexplicit.hh: Fix them.
This commit is contained in:
Damien Lefortier 2010-01-20 17:37:25 +01:00
parent 0d6fd3225a
commit 04827ef4a1
5 changed files with 63 additions and 32 deletions

View file

@ -284,6 +284,18 @@ namespace spot
return neg_acceptance_conditions_;
}
tgba_explicit_string::~tgba_explicit_string()
{
ns_map::iterator i;
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
{
tgba_explicit::state::iterator i2;
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
delete *i2;
delete i->second;
}
}
tgba_explicit::state*
tgba_explicit_string::add_default_init()
{
@ -302,9 +314,18 @@ namespace spot
tgba_explicit_formula::~tgba_explicit_formula()
{
ns_map::iterator i;
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
i->first->destroy();
ns_map::iterator i = name_state_map_.begin();
while (i != name_state_map_.end())
{
tgba_explicit::state::iterator i2;
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
delete *i2;
// Advance the iterator before deleting the formula.
const ltl::formula* s = i->first;
delete i->second;
++i;
s->destroy();
}
}
tgba_explicit::state* tgba_explicit_formula::add_default_init()