Fix memory leak for hashing with nondeterministic collations.
authorJeff Davis
Thu, 1 Dec 2022 19:26:32 +0000 (11:26 -0800)
committerJeff Davis
Thu, 1 Dec 2022 19:53:53 +0000 (11:53 -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 242333920e714f360d6e5b3f35f68c170e5e4dfd..2c00de5041808a498ff8c95e420ff83ca1d331bf 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 8fc84649f195491adaf550d2b43afacab745a46c..714cf22613d864aff72c0184b87df7bf5a2677bc 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));