From: Antony Dovgal Date: Tue, 2 Oct 2007 17:09:22 +0000 (+0000) Subject: ucnv_toUnicode() in ICU 3.8 requires target buffer size to be even, otherwise it... X-Git-Tag: RELEASE_2_0_0a1~1680 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=277eb1feee3b497a21f5a51cab7e6f632a771e4f;p=php ucnv_toUnicode() in ICU 3.8 requires target buffer size to be even, otherwise it bails out with U_ILLEGAL_ARGUMENT_ERROR this commit fixes endless loop (due to the absence of error catching) and also fixes the cause of the error --- diff --git a/main/streams/unicode_filter.c b/main/streams/unicode_filter.c index c51bc06365..0d27d34339 100644 --- a/main/streams/unicode_filter.c +++ b/main/streams/unicode_filter.c @@ -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)