aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-09-03 12:30:53 +0900
committerMichael Paquier <michael@paquier.xyz>2019-09-03 12:30:53 +0900
commit3a54eb1a383411765deb66e6081568ae6f8d9132 (patch)
treef8c4ee532b1412555b7d8533a1cfa16203b4bf80
parentf63a5ead9d04467e1c1847bd5e3d87c4dca6cd35 (diff)
downloadpostgresql-3a54eb1a383411765deb66e6081568ae6f8d9132.tar.gz
postgresql-3a54eb1a383411765deb66e6081568ae6f8d9132.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 b3115e4bea8..755ca6e277c 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1584,6 +1584,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
@@ -1707,6 +1708,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
@@ -1831,6 +1833,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