aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-09-03 12:31:08 +0900
committerMichael Paquier <michael@paquier.xyz>2019-09-03 12:31:08 +0900
commitf967a1fda89b8b96b363109af21d521ed9d50877 (patch)
tree5e361ce2996df9e1a6090634ad62527db6bc21f3
parent5524ef55818b77068ccbbf53f065dedcc6b50120 (diff)
downloadpostgresql-f967a1fda89b8b96b363109af21d521ed9d50877.tar.gz
postgresql-f967a1fda89b8b96b363109af21d521ed9d50877.zip
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
-rw-r--r--src/backend/utils/adt/formatting.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index a345c656050..c8a9f939d6b 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1551,6 +1551,7 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar);
+ pfree(buff_conv);
}
else
#endif
@@ -1673,6 +1674,7 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar);
+ pfree(buff_conv);
}
else
#endif
@@ -1796,6 +1798,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
&buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
pfree(buff_uchar);
+ pfree(buff_conv);
}
else
#endif