Skip to content

Commit

Permalink
Fix memory leak when updating chunk skip node (#254)
Browse files Browse the repository at this point in the history
When UpdateChunkSkipNodeMinMax() is executed, it may allocate memory for
non-fixed size data types. If the minimum or maximum value changes, the
previous value will be overwritten, resulting in a memory leak.
  • Loading branch information
japinli authored May 21, 2024
1 parent a4c3cf5 commit a9f7a23
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions columnar/src/backend/columnar/columnar_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ UpdateChunkSkipNodeMinMax(ColumnChunkSkipNode *chunkSkipNode, Datum columnValue,

if (minimumComparison < 0)
{
if (!columnTypeByValue)
pfree(DatumGetPointer(previousMinimum));

currentMinimum = DatumCopy(columnValue, columnTypeByValue, columnTypeLength);
}
else
Expand All @@ -768,6 +771,9 @@ UpdateChunkSkipNodeMinMax(ColumnChunkSkipNode *chunkSkipNode, Datum columnValue,

if (maximumComparison > 0)
{
if (!columnTypeByValue)
pfree(DatumGetPointer(previousMaximum));

currentMaximum = DatumCopy(columnValue, columnTypeByValue, columnTypeLength);
}
else
Expand Down

0 comments on commit a9f7a23

Please sign in to comment.