com php-src: Handle bogus string in intl_charFromString() .: ext/intl/intl_convertcpp.cpp

From: Date: Thu, 17 May 2012 15:23:53 +0000
Subject: com php-src: Handle bogus string in intl_charFromString() .: ext/intl/intl_convertcpp.cpp
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-69112@lists.php.net to get a copy of this message
Commit: 30bf2fbb9d92b66b2f40cb3383bbb00d5921269c Author: Gustavo André dos Santos Lopes <cataphract@php.net> Mon, 30 Apr 2012 15:29:36 +0200 Parents: 81d8f4079cac4e215e5ed98b5a6fd1f3a89e375f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=30bf2fbb9d92b66b2f40cb3383bbb00d5921269c Log: Handle bogus string in intl_charFromString(). Changed paths: M ext/intl/intl_convertcpp.cpp Diff: diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp index 8dddc702..5034028 100644 --- a/ext/intl/intl_convertcpp.cpp +++ b/ext/intl/intl_convertcpp.cpp @@ -48,9 +48,16 @@ int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCo } /* }}} */ -/* {{{ intl_charFromString */ +/* {{{ intl_charFromString + * 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) { + if (from.isBogus()) { + return FAILURE; + } + //the number of UTF-8 code units is not larger than that of UTF-16 code //units * 3 + 1 for the terminator int32_t capacity = from.length() * 3 + 1;

« previous php.cvs (#69112) next »