git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd94488)
Fix pfree issue in presorted DISTINCT aggregate code
2023年2月13日 10:38:21 +0000 (23:38 +1300)
2023年2月13日 10:38:21 +0000 (23:38 +1300)
The logic in this area was recently changed in 7da51590e, 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


diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 827c65cc852a2d300baa22b516c2d71abb53fd9e..19351fe34bf44f9599e2b23528893aa913ea192d 100644 (file)
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -4254,7 +4254,8 @@ ExecEvalPreOrderedDistinctSingle(AggState *aggstate, AggStatePerTrans pertrans)
pertrans->aggCollation,
pertrans->lastdatum, value))))
{
- if (pertrans->haslast && !pertrans->inputtypeByVal)
+ if (pertrans->haslast && !pertrans->inputtypeByVal &&
+ !pertrans->lastisnull)
pfree(DatumGetPointer(pertrans->lastdatum));
pertrans->haslast = true;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /