Fix potential leak of Analyzers added to tree during Analyzer::Done

Credit to OSS-Fuzz for discovery
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22630
This commit is contained in:
Jon Siwek 2020-05-27 15:51:34 -07:00
parent 433e1154da
commit d2eb701b7e

View file

@ -135,6 +135,20 @@ Analyzer::~Analyzer()
{
assert(finished);
// Make sure any late entries into the analyzer tree are handled (e.g.
// from some Done() implementation).
LOOP_OVER_GIVEN_CHILDREN(i, new_children)
{
if ( ! (*i)->finished )
(*i)->Done();
}
// Deletion of new_children done in separate loop in case a Done()
// implementation tries to inspect analyzer tree w/ assumption that
// all analyzers are still valid.
LOOP_OVER_GIVEN_CHILDREN(i, new_children)
delete *i;
LOOP_OVER_CHILDREN(i)
delete *i;