Skip to content

Commit e9ed833

Browse files
Plug memory leak in COMPACT_COUNT_DISTINCT's push down (#11)
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.
1 parent b1eb4ba commit e9ed833

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/ee/executors/aggregateexecutor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,10 @@ class ValuesToCompactAgg : public CompactCountDistinctAgg {
538538
{
539539
assert (type == VALUE_TYPE_VARBINARY);
540540
uint32_t byteSize = roaring().getSizeInBytes();
541-
char *serializedBytes = new char[byteSize];
541+
std::unique_ptr<char[]> serializedBytes(new char[byteSize]);
542542

543-
roaring().write(serializedBytes);
544-
return ValueFactory::getTempBinaryValue(serializedBytes, byteSize);
543+
roaring().write(serializedBytes.get());
544+
return ValueFactory::getTempBinaryValue(serializedBytes.get(), byteSize);
545545
}
546546
};
547547

0 commit comments

Comments
 (0)