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:
parent
4964c9a1a4
commit
995335618a
3 changed files with 25 additions and 2 deletions
|
|
@ -457,7 +457,17 @@ subformula: ATOMIC_PROP
|
|||
CHECK_EXISTING_NMAP(@1, $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);
|
||||
}
|
||||
delete $1;
|
||||
|
|
@ -484,7 +494,6 @@ subformula: ATOMIC_PROP
|
|||
|
||||
arg_list: subformula
|
||||
{
|
||||
// TODO: delete it whenever a parse error occurs on a subformula.
|
||||
$$ = new automatop::vec;
|
||||
$$->push_back($1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ main(int argc, char** argv)
|
|||
if (spot::eltl::format_parse_errors(std::cerr, p))
|
||||
{
|
||||
if (f != 0)
|
||||
{
|
||||
std::cout << f->dump() << std::endl;
|
||||
spot::ltl::destroy(f);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +49,9 @@ main(int argc, char** argv)
|
|||
|
||||
assert(f != 0);
|
||||
std::cout << f->dump() << std::endl;
|
||||
spot::ltl::destroy(f);
|
||||
|
||||
assert(f2 != 0);
|
||||
std::cout << f2->dump() << std::endl;
|
||||
spot::ltl::destroy(f2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue