Skip to content

Commit 30bf2fb

Browse files
committed
Handle bogus string in intl_charFromString().
1 parent 81d8f40 commit 30bf2fb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/intl/intl_convertcpp.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCo
4848
}
4949
/* }}} */
5050

51-
/* {{{ intl_charFromString */
51+
/* {{{ intl_charFromString
52+
* faster than doing intl_convert_utf16_to_utf8(&res, &res_len,
53+
* from.getBuffer(), from.length(), &status),
54+
* but consumes more memory */
5255
int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status)
5356
{
57+
if (from.isBogus()) {
58+
return FAILURE;
59+
}
60+
5461
//the number of UTF-8 code units is not larger than that of UTF-16 code
5562
//units * 3 + 1 for the terminator
5663
int32_t capacity = from.length() * 3 + 1;

0 commit comments

Comments
 (0)