]> granicus.if.org Git - php/commitdiff
ucnv_toUnicode() in ICU 3.8 requires target buffer size to be even, otherwise it...
authorAntony Dovgal <tony2001@php.net>
Tue, 2 Oct 2007 17:09:22 +0000 (17:09 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 2 Oct 2007 17:09:22 +0000 (17:09 +0000)
this commit fixes endless loop (due to the absence of error catching) and also fixes the cause of the error

main/streams/unicode_filter.c

index c51bc0636515b220aada5298e3eba52490bda2ec..0d27d343399d53a25653572e896db463c754551c 100644 (file)
@@ -144,10 +144,18 @@ static php_stream_filter_status_t php_unicode_from_string_filter(
                        UErrorCode errCode = U_ZERO_ERROR;
                        php_stream_bucket *new_bucket;
 
+                       if ((destlen & 1) != 0) {
+                               destlen++;
+                       }
+
                        destp = destbuf = (UChar *)pemalloc(destlen, data->is_persistent);
 
                        ucnv_toUnicode(data->conv, &destp, (UChar*)((char*)destbuf + destlen), (const char**)&src, src + remaining, NULL, FALSE, &errCode);
-                       /* UTODO: Error catching */
+
+                       if (errCode != U_ZERO_ERROR) {
+                               pefree(destp, data->is_persistent);
+                               break;
+                       }
 
                        new_bucket = php_stream_bucket_new_unicode(stream, destbuf, destp - destbuf, 1, data->is_persistent TSRMLS_CC);
                        php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
@@ -246,7 +254,6 @@ php_stream_filter_ops php_unicode_tidy_filter_ops = {
 };
 /* }}} */
 
-
 /* {{{ unicode.* factory */
 
 static php_stream_filter *php_unicode_filter_create(const char *filtername, zval *filterparams, int persistent TSRMLS_DC)