From: Felipe Pena Date: Fri, 12 Sep 2008 17:30:53 +0000 (+0000) Subject: - Fixed endless loop and segfault X-Git-Tag: BEFORE_HEAD_NS_CHANGE~414 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c9ee1a71c16e6a11d2327c13bed97dca7b66a7f;p=php - Fixed endless loop and segfault --- diff --git a/ext/unicode/tests/textiterator_getall_001.phpt b/ext/unicode/tests/textiterator_getall_001.phpt new file mode 100644 index 0000000000..e819388c09 --- /dev/null +++ b/ext/unicode/tests/textiterator_getall_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +TextIterator::getAll(): Simple test +--FILE-- +getAll()); + +?> +--EXPECT-- +array(4) { + [0]=> + unicode(1) "a" + [1]=> + unicode(1) "s" + [2]=> + unicode(1) "d" + [3]=> + unicode(1) "a" +} diff --git a/ext/unicode/tests/textiterator_next_001.phpt b/ext/unicode/tests/textiterator_next_001.phpt new file mode 100644 index 0000000000..2d2200fa61 --- /dev/null +++ b/ext/unicode/tests/textiterator_next_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +TextIterator::next(): Testing with no data +--FILE-- +next()); + +?> +--EXPECTF-- +Warning: TextIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d +int(-1) diff --git a/ext/unicode/unicode_iterators.c b/ext/unicode/unicode_iterators.c index a3e66a3f58..61a381b6ba 100644 --- a/ext/unicode/unicode_iterators.c +++ b/ext/unicode/unicode_iterators.c @@ -157,6 +157,11 @@ static void text_iter_cp_next(text_iter_obj* object, long flags TSRMLS_DC) if (object->u.cp.offset == UBRK_DONE) { return; } + + if (object->text == NULL) { + object->u.cp.offset = object->u.cp.cp_offset = UBRK_DONE; + return; + } if (flags & ITER_REVERSE) { U16_BACK_1(object->text, 0, object->u.cp.offset);