Fix memory leak for hashing with nondeterministic collations.
authorJeff Davis <jdavis@postgresql.org>
Thu, 1 Dec 2022 19:26:32 +0000 (11:26 -0800)
committerJeff Davis <jdavis@postgresql.org>
Thu, 1 Dec 2022 19:49:15 +0000 (11:49 -0800)
Backpatch through 12, where nondeterministic collations were
introduced (5e1963fb76).

Backpatch-through: 12

src/backend/access/hash/hashfunc.c
src/backend/utils/adt/varchar.c

index b57ed946c42bb54ede800e95045aa937a8dbad85..f890f79ee180a8dd931d3974a0e99d611db80271 100644 (file)
@@ -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));
 
index 68e2e6f7a719866eacc506e1780f6d1b58951599..09c483d6ff85c3a5cb76ff598a0914ffdfcec2c0 100644 (file)
@@ -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));