summaryrefslogtreecommitdiff
path: root/ext/intl/intl_convertcpp.cpp
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-12-29 02:17:15 -0800
committerStanislav Malyshev <stas@php.net>2014-12-29 14:06:12 -0800
commit82f3d3658315513bdb8136371c6b46ea6297eb22 (patch)
tree6bdee5087d8b5a0c75db0ece8e20189cacfc090a /ext/intl/intl_convertcpp.cpp
parentee7decb7ff7b8e81b595c01cfb6b5719bb8c520e (diff)
downloadphp-git-82f3d3658315513bdb8136371c6b46ea6297eb22.tar.gz
cleanup intl types
Diffstat (limited to 'ext/intl/intl_convertcpp.cpp')
-rw-r--r--ext/intl/intl_convertcpp.cpp13
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;
}