Fix some memory leaks.

* src/eltlparse/eltlparse.yy: Free the automatop::vec when
CHECK_ARITY fails while parsing an automatop.
* src/eltltest/acc.cc: Free all constructed formulae.
This commit is contained in:
Damien Lefortier 2009-09-07 16:41:18 +02:00
parent 4964c9a1a4
commit 995335618a
3 changed files with 25 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2009-09-07 Damien Lefortier <dam@lrde.epita.fr>
Fix some memory leaks.
* src/eltlparse/eltlparse.yy: Free the automatop::vec when
CHECK_ARITY fails while parsing an automatop.
* src/eltltest/acc.cc: Free all constructed formulae.
2009-09-07 Alexandre Duret-Lutz <adl@lrde.epita.fr> 2009-09-07 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Fix a memory leak in reduce_tau03(). Fix a memory leak in reduce_tau03().

View file

@ -457,7 +457,17 @@ subformula: ATOMIC_PROP
CHECK_EXISTING_NMAP(@1, $1); CHECK_EXISTING_NMAP(@1, $1);
nfa::ptr np = nmap[*$1]; nfa::ptr np = nmap[*$1];
CHECK_ARITY(@1, $1, $3->size(), np->arity()); /// Easily handle deletion of $3 when CHECK_ARITY fails.
int i = $3->size();
if ($3->size() != np->arity())
{
automatop::vec::iterator it = $3->begin();
while (it != $3->end())
spot::ltl::destroy(*it++);
delete $3;
}
CHECK_ARITY(@1, $1, i, np->arity());
$$ = automatop::instance(np, $3, false); $$ = automatop::instance(np, $3, false);
} }
delete $1; delete $1;
@ -484,7 +494,6 @@ subformula: ATOMIC_PROP
arg_list: subformula arg_list: subformula
{ {
// TODO: delete it whenever a parse error occurs on a subformula.
$$ = new automatop::vec; $$ = new automatop::vec;
$$->push_back($1); $$->push_back($1);
} }

View file

@ -36,7 +36,10 @@ main(int argc, char** argv)
if (spot::eltl::format_parse_errors(std::cerr, p)) if (spot::eltl::format_parse_errors(std::cerr, p))
{ {
if (f != 0) if (f != 0)
{
std::cout << f->dump() << std::endl; std::cout << f->dump() << std::endl;
spot::ltl::destroy(f);
}
return 1; return 1;
} }
@ -46,6 +49,9 @@ main(int argc, char** argv)
assert(f != 0); assert(f != 0);
std::cout << f->dump() << std::endl; std::cout << f->dump() << std::endl;
spot::ltl::destroy(f);
assert(f2 != 0); assert(f2 != 0);
std::cout << f2->dump() << std::endl; std::cout << f2->dump() << std::endl;
spot::ltl::destroy(f2);
} }