Skip to content

Commit 604d206

Browse files
committed
Fix memory leak with lower, upper and initcap with ICU-provided collations
The leak happens in str_tolower, str_toupper and str_initcap, which are used in several places including their equivalent SQL-level functions, and can only be triggered when using an ICU-provided collation when converting the input string. b615920 fixed a similar leak. Backpatch down 10 where ICU collations have been introduced. Author: Konstantin Knizhnik Discussion: https://postgr.es/m/94c0ad0a-cbc2-e4a3-7829-2bdeaf9146db@postgrespro.ru Backpatch-through: 10
1 parent 3080f8f commit 604d206

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
15611561
&buff_conv, buff_uchar, len_uchar);
15621562
icu_from_uchar(&result, buff_conv, len_conv);
15631563
pfree(buff_uchar);
1564+
pfree(buff_conv);
15641565
}
15651566
else
15661567
#endif
@@ -1685,6 +1686,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
16851686
&buff_conv, buff_uchar, len_uchar);
16861687
icu_from_uchar(&result, buff_conv, len_conv);
16871688
pfree(buff_uchar);
1689+
pfree(buff_conv);
16881690
}
16891691
else
16901692
#endif
@@ -1810,6 +1812,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
18101812
&buff_conv, buff_uchar, len_uchar);
18111813
icu_from_uchar(&result, buff_conv, len_conv);
18121814
pfree(buff_uchar);
1815+
pfree(buff_conv);
18131816
}
18141817
else
18151818
#endif

0 commit comments

Comments
 (0)