Skip to content

Commit

Permalink
Plug memory leak in COMPACT_COUNT_DISTINCT's push down (#11)
Browse files Browse the repository at this point in the history
I spotted what appears to be a memory leak in ValuesToCompactAgg (COMPACT_COUNT_DISTINCT's "push down" function). The code allocates a new `char*` of size `byteSize` but never deallocates it. The pointer is passed to `ValueFactory::getTempBinary(…)`, which copies the given data rather than taking ownership of the pointer.
  • Loading branch information
rkennedy-mode authored Apr 13, 2020
1 parent b1eb4ba commit e9ed833
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ee/executors/aggregateexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,10 @@ class ValuesToCompactAgg : public CompactCountDistinctAgg {
{
assert (type == VALUE_TYPE_VARBINARY);
uint32_t byteSize = roaring().getSizeInBytes();
char *serializedBytes = new char[byteSize];
std::unique_ptr<char[]> serializedBytes(new char[byteSize]);

roaring().write(serializedBytes);
return ValueFactory::getTempBinaryValue(serializedBytes, byteSize);
roaring().write(serializedBytes.get());
return ValueFactory::getTempBinaryValue(serializedBytes.get(), byteSize);
}
};

Expand Down

0 comments on commit e9ed833

Please sign in to comment.