Commit 3a54eb1a authored by Michael Paquier's avatar Michael Paquier

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.

b6159202 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
parent f63a5ead
...@@ -1584,6 +1584,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid) ...@@ -1584,6 +1584,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar); &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv); icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar); pfree(buff_uchar);
pfree(buff_conv);
} }
else else
#endif #endif
...@@ -1707,6 +1708,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid) ...@@ -1707,6 +1708,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar); &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv); icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar); pfree(buff_uchar);
pfree(buff_conv);
} }
else else
#endif #endif
...@@ -1831,6 +1833,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid) ...@@ -1831,6 +1833,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar); &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv); icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar); pfree(buff_uchar);
pfree(buff_conv);
} }
else else
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment