tony2001                Tue Oct  2 17:09:22 2007 UTC

  Modified files:              
    /php-src/main/streams       unicode_filter.c 
  Log:
  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
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/streams/unicode_filter.c?r1=1.6&r2=1.7&diff_format=u
Index: php-src/main/streams/unicode_filter.c
diff -u php-src/main/streams/unicode_filter.c:1.6 
php-src/main/streams/unicode_filter.c:1.7
--- php-src/main/streams/unicode_filter.c:1.6   Mon Jan  1 09:29:36 2007
+++ php-src/main/streams/unicode_filter.c       Tue Oct  2 17:09:22 2007
@@ -14,7 +14,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: unicode_filter.c,v 1.6 2007/01/01 09:29:36 sebastian Exp $ */
+/* $Id: unicode_filter.c,v 1.7 2007/10/02 17:09:22 tony2001 Exp $ */
 
 
 #include "php.h"
@@ -144,10 +144,18 @@
                        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 @@
 };
 /* }}} */
 
-
 /* {{{ unicode.* factory */
 
 static php_stream_filter *php_unicode_filter_create(const char *filtername, 
zval *filterparams, int persistent TSRMLS_DC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to