Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita3b8d91

Browse files
committed
Fix theoretical bug in tuplesort
This fixes a theoretical bug in tuplesort.c which, if a bounded sort wasused in combination with a byval Datum sort (tuplesort_begin_datum), whenswitching the sort to a bounded heap in make_bounded_heap(), we'd callfree_sort_tuple(). The problem was that when sorting Datums of a byvaltype, the tuple is NULL and free_sort_tuple() would free the memory for itregardless of that. This would result in a crash.Here we fix that simply by adding a check to see if the tuple is NULLbefore trying to disassociate and free any memory belonging to it.The reason this bug is only theoretical is that nowhere in the currentcode base do we do tuplesort_set_bound() when performing a Datum sort.However, let's backpatch a fix for this as if any extension uses the codein this way then it's likely to cause problems.Author: Ronan DunklauDiscussion:https://postgr.es/m/CAApHDvpdoqNC5FjDb3KUTSMs5dg6f+XxH4Bg_dVcLi8UYAG3EQ@mail.gmail.comBackpatch-through: 9.6, oldest supported version
1 parente75da4f commita3b8d91

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎src/backend/utils/sort/tuplesort.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4773,6 +4773,9 @@ leader_takeover_tapes(Tuplesortstate *state)
47734773
staticvoid
47744774
free_sort_tuple(Tuplesortstate*state,SortTuple*stup)
47754775
{
4776-
FREEMEM(state,GetMemoryChunkSpace(stup->tuple));
4777-
pfree(stup->tuple);
4776+
if (stup->tuple)
4777+
{
4778+
FREEMEM(state,GetMemoryChunkSpace(stup->tuple));
4779+
pfree(stup->tuple);
4780+
}
47784781
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp