]> granicus.if.org Git - php/commitdiff
Handle bogus string in intl_charFromString().
authorGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 30 Apr 2012 13:29:36 +0000 (15:29 +0200)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 17 May 2012 15:23:53 +0000 (17:23 +0200)
ext/intl/intl_convertcpp.cpp

index 8dddc7029303a6460556b25b227c4ba346192d8b..503402871cd57824b91e691c3793037cad247566 100644 (file)
@@ -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;