From: Jeff Davis Date: Thu, 1 Dec 2022 19:26:32 +0000 (-0800) Subject: Fix memory leak for hashing with nondeterministic collations. X-Git-Tag: REL_15_2~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9377b4f30a14e1c79183b3138fa88fc99d4a872a;p=thirdparty%2Fpostgresql.git Fix memory leak for hashing with nondeterministic collations. Backpatch through 12, where nondeterministic collations were introduced (5e1963fb76). Backpatch-through: 12 --- diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index b57ed946c42..f890f79ee18 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 bbeb0a2653a..63a2073a429 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -1030,6 +1030,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); @@ -1091,6 +1092,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));