From edf12e7bbd0f5cf6b3c4f4d6b2dad8586b10dcc6 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Thu, 1 Dec 2022 11:26:32 -0800 Subject: [PATCH] Fix memory leak for hashing with nondeterministic collations. Backpatch through 12, where nondeterministic collations were introduced (5e1963fb76). Backpatch-through: 12 --- src/backend/access/hash/hashfunc.c | 2 ++ src/backend/utils/adt/varchar.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index b57ed946c4..f890f79ee1 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -303,6 +303,7 @@ hashtext(PG_FUNCTION_ARGS) buf = palloc(bsize); ucol_getSortKey(mylocale->info.icu.ucol, uchar, ulen, buf, bsize); + pfree(uchar); result = hash_any(buf, bsize); @@ -360,6 +361,7 @@ hashtextextended(PG_FUNCTION_ARGS) buf = palloc(bsize); ucol_getSortKey(mylocale->info.icu.ucol, uchar, ulen, buf, bsize); + pfree(uchar); result = hash_any_extended(buf, bsize, PG_GETARG_INT64(1)); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 68e2e6f7a7..09c483d6ff 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -1031,6 +1031,7 @@ hashbpchar(PG_FUNCTION_ARGS) buf = palloc(bsize); ucol_getSortKey(mylocale->info.icu.ucol, uchar, ulen, buf, bsize); + pfree(uchar); result = hash_any(buf, bsize); @@ -1092,6 +1093,7 @@ hashbpcharextended(PG_FUNCTION_ARGS) buf = palloc(bsize); ucol_getSortKey(mylocale->info.icu.ucol, uchar, ulen, buf, bsize); + pfree(uchar); result = hash_any_extended(buf, bsize, PG_GETARG_INT64(1)); -- 2.39.5