Bug Description:
-----------------
str_split() returns extra characters when given string is not multiple of given length. For example if the given string size is 22 and split length is 5, then the last element of the returned array contains 5 or more than 5 chars, which is wrong. The last element of the return array should only contain 2 chars.
The bug only occurs on PHP6 with UNICODE ON.

It can be fixed by changing only a single line of the code.
Please give a look at the attached patch, I don't have CVS access to commit it.
Thanks

Claudio Cherubino
Index: ext/standard/string.c
===================================================================
RCS file: /repository/php-src/ext/standard/string.c,v
retrieving revision 1.655
diff -u -r1.655 string.c
--- ext/standard/string.c       7 Oct 2007 05:15:06 -0000       1.655
+++ ext/standard/string.c       15 Nov 2007 17:29:00 -0000
@@ -7802,7 +7802,7 @@
        }
 
        if (p != (str.s + str_len * charsize)) {
-               add_next_index_zstrl(return_value, str_type, ZSTR(p), (str.s +
str_len * charsize - p), 1);
+               add_next_index_zstrl(return_value, str_type, ZSTR(p), (str.s +
str_len * charsize - p)/charsize, 1);
        }
 }
 /* }}} */
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to