Skip to content

Commit d2331cc

Browse files
Jinesh Patelnikic
Jinesh Patel
authored andcommitted
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).
1 parent ed099ab commit d2331cc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/intl/msgformat/msgformat_helpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
185185

186186
if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NAME) {
187187
UnicodeString argName = mp.getSubstring(name_part);
188-
if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length())) == NULL) {
188+
if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length() * sizeof(UChar))) == NULL) {
189189
/* not found already; create new entry in HT */
190190
Formattable::Type bogusType = Formattable::kObject;
191-
if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(),
191+
if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length() * sizeof(UChar),
192192
(void*)&bogusType, sizeof(bogusType))) == NULL) {
193193
intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
194194
"Write to argument types hash table failed", 0);
@@ -450,7 +450,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
450450
continue;
451451
}
452452

453-
storedArgType = (Formattable::Type*)zend_hash_str_find_ptr(types, (char*)key.getBuffer(), key.length());
453+
storedArgType = (Formattable::Type*)zend_hash_str_find_ptr(types, (char*)key.getBuffer(), key.length() * sizeof(UChar));
454454
}
455455

456456
if (storedArgType != NULL) {

0 commit comments

Comments
 (0)