From: | David Rowley <drowley(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix theoretical bug in tuplesort |
Date: | 2021-07-13 00:45:59 |
Message-ID: | E1m36Yh-0006bb-DZ@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix theoretical bug in tuplesort
This fixes a theoretical bug in tuplesort.c which, if a bounded sort was
used in combination with a byval Datum sort (tuplesort_begin_datum), when
switching the sort to a bounded heap in make_bounded_heap(), we'd call
free_sort_tuple(). The problem was that when sorting Datums of a byval
type, the tuple is NULL and free_sort_tuple() would free the memory for it
regardless of that. This would result in a crash.
Here we fix that simply by adding a check to see if the tuple is NULL
before trying to disassociate and free any memory belonging to it.
The reason this bug is only theoretical is that nowhere in the current
code 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 code
in this way then it's likely to cause problems.
Author: Ronan Dunklau
Discussion: https://postgr.es/m/CAApHDvpdoqNC5FjDb3KUTSMs5dg6f+XxH4Bg_dVcLi8UYAG3EQ@mail.gmail.com
Backpatch-through: 9.6, oldest supported version
Branch
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/187e9c3996aa6d82f95385c81d532610fb021309
Modified Files
--------------
src/backend/utils/sort/tuplesort.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2021-07-13 00:46:36 | pgsql: Fix theoretical bug in tuplesort |
Previous Message | David Rowley | 2021-07-13 00:45:18 | pgsql: Fix theoretical bug in tuplesort |