Skip to content

Commit ec5a010

Browse files
committed
Fix pfree issue in presorted DISTINCT aggregate code
The logic in this area was recently changed in 7da5159, however, in that commit, I neglected to consider that the conditions in which we should pfree the old Datum needed to be updated after that change. This could result in trying to pfree a NULL value, as was demonstrated by Alexander Lakhin. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/4103db46-d888-6d1d-e88d-87c21ed99472@gmail.com
1 parent bd94488 commit ec5a010

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/executor/execExprInterp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4254,7 +4254,8 @@ ExecEvalPreOrderedDistinctSingle(AggState *aggstate, AggStatePerTrans pertrans)
42544254
pertrans->aggCollation,
42554255
pertrans->lastdatum, value))))
42564256
{
4257-
if (pertrans->haslast && !pertrans->inputtypeByVal)
4257+
if (pertrans->haslast && !pertrans->inputtypeByVal &&
4258+
!pertrans->lastisnull)
42584259
pfree(DatumGetPointer(pertrans->lastdatum));
42594260

42604261
pertrans->haslast = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy