Skip to content

Commit 2fde8e4

Browse files
committed
Robustify tuplesort's free_sort_tuple function
4146925 went to the trouble of removing a theoretical bug from free_sort_tuple by checking if the tuple was NULL before freeing it. Let's make this a little more robust by also setting the tuple to NULL so that should we be called again we won't end up doing a pfree on the already pfree'd tuple. Per advice from Tom Lane. Discussion: https://postgr.es/m/3188192.1626136953@sss.pgh.pa.us Backpatch-through: 9.6, same as 4146925
1 parent 204f646 commit 2fde8e4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,5 +4701,6 @@ free_sort_tuple(Tuplesortstate *state, SortTuple *stup)
47014701
{
47024702
FREEMEM(state, GetMemoryChunkSpace(stup->tuple));
47034703
pfree(stup->tuple);
4704+
stup->tuple = NULL;
47044705
}
47054706
}

0 commit comments

Comments
 (0)