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

Commit1def747

Browse files
committed
Fix inadequately-tested code path in tuplesort_skiptuples().
Per report from Jeff Davis.
1 parent4eeda92 commit1def747

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,8 @@ tuplesort_getdatum(Tuplesortstate *state, bool forward,
17251725
bool
17261726
tuplesort_skiptuples(Tuplesortstate*state,int64ntuples,boolforward)
17271727
{
1728+
MemoryContextoldcontext;
1729+
17281730
/*
17291731
* We don't actually support backwards skip yet, because no callers need
17301732
* it.The API is designed to allow for that later, though.
@@ -1760,18 +1762,23 @@ tuplesort_skiptuples(Tuplesortstate *state, int64 ntuples, bool forward)
17601762
* We could probably optimize these cases better, but for now it's
17611763
* not worth the trouble.
17621764
*/
1765+
oldcontext=MemoryContextSwitchTo(state->sortcontext);
17631766
while (ntuples-->0)
17641767
{
17651768
SortTuplestup;
17661769
boolshould_free;
17671770

17681771
if (!tuplesort_gettuple_common(state,forward,
17691772
&stup,&should_free))
1773+
{
1774+
MemoryContextSwitchTo(oldcontext);
17701775
return false;
1771-
if (should_free)
1776+
}
1777+
if (should_free&&stup.tuple)
17721778
pfree(stup.tuple);
17731779
CHECK_FOR_INTERRUPTS();
17741780
}
1781+
MemoryContextSwitchTo(oldcontext);
17751782
return true;
17761783

17771784
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp