diff options
author | Jakub Zelenka <bukka@php.net> | 2015-01-04 17:17:00 +0000 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2015-01-04 17:17:00 +0000 |
commit | 32d54acd00cfff8f501c0761ffa662cf9556b60e (patch) | |
tree | 61abfce6a6a4baaa48cc680df8828d178be0dfe7 /ext/intl/intl_convertcpp.cpp | |
parent | 8e102504494d49a9218d0948dc8a7de36753ebe5 (diff) | |
parent | 2269b1801d3e55d6895ff4c066e9f485c1f5ac2f (diff) | |
download | php-git-32d54acd00cfff8f501c0761ffa662cf9556b60e.tar.gz |
Merge branch 'master' into jsond
Diffstat (limited to 'ext/intl/intl_convertcpp.cpp')
-rw-r--r-- | ext/intl/intl_convertcpp.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp index f52348bc25..3507737616 100644 --- a/ext/intl/intl_convertcpp.cpp +++ b/ext/intl/intl_convertcpp.cpp @@ -25,11 +25,16 @@ extern "C" { } /* {{{ intl_stringFromChar */ -int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status) +int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status) { + if(str_len > INT32_MAX) { + *status = U_BUFFER_OVERFLOW_ERROR; + ret.setToBogus(); + return FAILURE; + } //the number of UTF-16 code units is not larger than that of UTF-8 code //units, + 1 for the terminator - int32_t capacity = str_len + 1; + int32_t capacity = (int32_t)str_len + 1; //no check necessary -- if NULL will fail ahead UChar *utf16 = ret.getBuffer(capacity); @@ -51,7 +56,7 @@ int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCo * faster than doing intl_convert_utf16_to_utf8(&res, &res_len, * from.getBuffer(), from.length(), &status), * but consumes more memory */ -int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status) +int intl_charFromString(const UnicodeString &from, char **res, size_t *res_len, UErrorCode *status) { if (from.isBogus()) { return FAILURE; @@ -82,7 +87,7 @@ int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UEr return FAILURE; } (*res)[actual_len] = '\0'; - *res_len = (int)actual_len; + *res_len = actual_len; return SUCCESS; } |