Fix memory leak for hashing with nondeterministic collations.
authorJeff Davis <[email protected]>
Thu, 1 Dec 2022 19:26:32 +0000 (11:26 -0800)
committerJeff Davis <[email protected]>
Thu, 1 Dec 2022 19:52:06 +0000 (11:52 -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 06141d853fa1dbc6f3ba5a2e1f87cb7e4541add2..961d069c381e74c3b3e3c59c3792116936f85e93 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 b595ab9569cfd768d76e75a4c0ac50f0e995c992..7144622df8a66ad9a3df152e0bdfec827e6f04a1 100644 (file)
@@ -1020,6 +1020,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);
 
@@ -1081,6 +1082,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));