1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-4043 Fix memory leaks - 1 (second attempt)

simpleScalarFilterToParseTree() performs a dynamic allocation
of a ParseTree object, but this memory is never freed later.
We now keep track of this allocation and perform the delete
in ~CSEP/CSEP::unserialize() after the query finishes.
This commit is contained in:
Gagan Goel
2020-06-19 15:39:49 -04:00
parent 6d5053e651
commit b48cf64b78
8 changed files with 75 additions and 2 deletions

View File

@ -173,6 +173,26 @@ CalpontSelectExecutionPlan::~CalpontSelectExecutionPlan()
fFilters = NULL;
fHaving = NULL;
if (!fDynamicParseTreeVec.empty())
{
for (auto& parseTree : fDynamicParseTreeVec)
{
if (parseTree)
{
// 'delete fFilters;' above has already deleted objects pointed
// to by parseTree->left()/right()/data(), so we set the
// pointers to NULL here before calling 'delete parseTree;'
parseTree->left((ParseTree*) (NULL));
parseTree->right((ParseTree*) (NULL));
parseTree->data((TreeNode*) (NULL));
delete parseTree;
parseTree = NULL;
}
}
fDynamicParseTreeVec.clear();
}
}
/**
@ -537,6 +557,26 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
fHaving = 0;
}
if (!fDynamicParseTreeVec.empty())
{
for (auto& parseTree : fDynamicParseTreeVec)
{
if (parseTree)
{
// 'delete fFilters;' above has already deleted objects pointed
// to by parseTree->left()/right()/data(), so we set the
// pointers to NULL here before calling 'delete parseTree;'
parseTree->left((ParseTree*) (NULL));
parseTree->right((ParseTree*) (NULL));
parseTree->data((TreeNode*) (NULL));
delete parseTree;
parseTree = NULL;
}
}
fDynamicParseTreeVec.clear();
}
messageqcpp::ByteStream::quadbyte size;
messageqcpp::ByteStream::quadbyte i;