Skip to content

Commit b48ecf8

Browse files
committed
In bttext_abbrev_convert, move pfree to the right place.
Without this, we might access memory that's already been freed, or leak memory if in the C locale. Peter Geoghegan
1 parent 47fe4d2 commit b48ecf8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,13 +2034,9 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
20342034
}
20352035

20362036
/* Just like strcoll(), strxfrm() expects a NUL-terminated string */
2037-
memcpy(tss->buf1, VARDATA_ANY(authoritative), len);
2037+
memcpy(tss->buf1, authoritative_data, len);
20382038
tss->buf1[len] = '\0';
20392039

2040-
/* Don't leak memory here */
2041-
if (PointerGetDatum(authoritative) != original)
2042-
pfree(authoritative);
2043-
20442040
for (;;)
20452041
{
20462042
#ifdef HAVE_LOCALE_T
@@ -2108,6 +2104,10 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
21082104

21092105
addHyperLogLog(&tss->abbr_card, hash);
21102106

2107+
/* Don't leak memory here */
2108+
if (PointerGetDatum(authoritative) != original)
2109+
pfree(authoritative);
2110+
21112111
return res;
21122112
}
21132113

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy