Skip to content

Commit 47e1224

Browse files
committed
Fix memory leak for hashing with nondeterministic collations.
Backpatch through 12, where nondeterministic collations were introduced (5e1963f). Backpatch-through: 12
1 parent 7ec2bfe commit 47e1224

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/backend/access/hash/hashfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ hashtext(PG_FUNCTION_ARGS)
303303
buf = palloc(bsize);
304304
ucol_getSortKey(mylocale->info.icu.ucol,
305305
uchar, ulen, buf, bsize);
306+
pfree(uchar);
306307

307308
result = hash_any(buf, bsize);
308309

@@ -360,6 +361,7 @@ hashtextextended(PG_FUNCTION_ARGS)
360361
buf = palloc(bsize);
361362
ucol_getSortKey(mylocale->info.icu.ucol,
362363
uchar, ulen, buf, bsize);
364+
pfree(uchar);
363365

364366
result = hash_any_extended(buf, bsize, PG_GETARG_INT64(1));
365367

src/backend/utils/adt/varchar.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ hashbpchar(PG_FUNCTION_ARGS)
10201020
buf = palloc(bsize);
10211021
ucol_getSortKey(mylocale->info.icu.ucol,
10221022
uchar, ulen, buf, bsize);
1023+
pfree(uchar);
10231024

10241025
result = hash_any(buf, bsize);
10251026

@@ -1081,6 +1082,7 @@ hashbpcharextended(PG_FUNCTION_ARGS)
10811082
buf = palloc(bsize);
10821083
ucol_getSortKey(mylocale->info.icu.ucol,
10831084
uchar, ulen, buf, bsize);
1085+
pfree(uchar);
10841086

10851087
result = hash_any_extended(buf, bsize, PG_GETARG_INT64(1));
10861088

0 commit comments

Comments
 (0)