summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinesh Patel <jineshpatel@jineshs-mbp.war.can.ibm.com>2019-07-29 14:19:52 -0400
committerNikita Popov <nikita.ppv@gmail.com>2019-09-25 10:30:33 +0200
commitd2331cc3f2fee2228b82def81c1e9557dd73d77c (patch)
tree45ef41a46a997256084439ae9d35c6b33e95a980
parented099ab18642eb1815b43c71f3fb0326f723c69d (diff)
downloadphp-git-d2331cc3f2fee2228b82def81c1e9557dd73d77c.tar.gz
Fix hash key length in umsg_parse_format()
Fix array length passed to zend_hash_str_find_ptr() casting from UChar array to char array requires mul by sizeof(UChar).
-rw-r--r--ext/intl/msgformat/msgformat_helpers.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp
index 25fa3e5e1f..3e9b0d7f52 100644
--- a/ext/intl/msgformat/msgformat_helpers.cpp
+++ b/ext/intl/msgformat/msgformat_helpers.cpp
@@ -185,10 +185,10 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NAME) {
UnicodeString argName = mp.getSubstring(name_part);
- if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length())) == NULL) {
+ if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length() * sizeof(UChar))) == NULL) {
/* not found already; create new entry in HT */
Formattable::Type bogusType = Formattable::kObject;
- if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(),
+ if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length() * sizeof(UChar),
(void*)&bogusType, sizeof(bogusType))) == NULL) {
intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
"Write to argument types hash table failed", 0);
@@ -450,7 +450,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
continue;
}
- storedArgType = (Formattable::Type*)zend_hash_str_find_ptr(types, (char*)key.getBuffer(), key.length());
+ storedArgType = (Formattable::Type*)zend_hash_str_find_ptr(types, (char*)key.getBuffer(), key.length() * sizeof(UChar));
}
if (storedArgType != NULL) {