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

Commitd858994

Browse files
committed
Fix use-after-free around DISTINCT transition function calls.
Have tuplesort_gettupleslot() copy the contents of its current table slotas needed. This is based on an approach taken by tuplestore_gettupleslot().In the future, tuplesort_gettupleslot() may also be taught to avoid copyingthe tuple where caller can determine that that is safe (thetuplestore_gettupleslot() interface already offers this option to callers).Patch by Peter Geoghegan. Fixes bug #14344, reported by Regina Obe.Report: <20160929035538.20224.39628@wrigleys.postgresql.org>Backpatch-through: 9.6
1 parent9e083fd commitd858994

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,10 @@ tuplesort_gettuple_common(Tuplesortstate *state, bool forward,
20842084
* determination of "non-equal tuple" based on simple binary inequality. A
20852085
* NULL value in leading attribute will set abbreviated value to zeroed
20862086
* representation, which caller may rely on in abbreviated inequality check.
2087+
*
2088+
* The slot receives a copied tuple (sometimes allocated in caller memory
2089+
* context) that will stay valid regardless of future manipulations of the
2090+
* tuplesort's state.
20872091
*/
20882092
bool
20892093
tuplesort_gettupleslot(Tuplesortstate*state,boolforward,
@@ -2104,6 +2108,11 @@ tuplesort_gettupleslot(Tuplesortstate *state, bool forward,
21042108
if (state->sortKeys->abbrev_converter&&abbrev)
21052109
*abbrev=stup.datum1;
21062110

2111+
if (!should_free)
2112+
{
2113+
stup.tuple=heap_copy_minimal_tuple((MinimalTuple)stup.tuple);
2114+
should_free= true;
2115+
}
21072116
ExecStoreMinimalTuple((MinimalTuple)stup.tuple,slot,should_free);
21082117
return true;
21092118
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp