|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77006 reaching the end of a intliterator makes it unusable
Submitted: 2018-10-12 06:59 UTC Modified: 2021-11-11 11:18 UTC
From: dontspamwespls at example dot org Assigned:
Status: Open Package: I18N and L10N related
PHP Version: 7.3.0RC3 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: dontspamwespls at example dot org
New email:
PHP Version: OS:


 [2018-10-12 06:59 UTC] dontspamwespls at example dot org
once valid() becomes false, previous() stops working

Test script:

$iteratorx = IntlCodePointBreakIterator::createCodePointInstance();

$iterator = $iteratorx->getPartsIterator();
$iteratorx->previous(); // previous works
echo $iterator->current() . "\n"; // c... all fine

$iterator->next(); // no more code points, so it's invalid
var_dump($iterator->valid()); // false
var_dump($iterator->current()); // prints weird stuff... whatever...

$iteratorx->previous(); // cannot go back
var_dump($iterator->valid()); // broken
var_dump($iterator->current()); // broken

Expected result:
I expect valid() to be true after previous(), and current() set to the last code point


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-15 11:04 UTC]
> var_dump($iterator->current()); // prints weird stuff... whatever...

That is because an IS_UNDEF value is returned.  Possible fix:

 ext/intl/common/common_enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp
index adc7034d36..1e1b5ecb50 100644
--- a/ext/intl/common/common_enum.cpp
+++ b/ext/intl/common/common_enum.cpp
@@ -218,7 +218,7 @@ static PHP_METHOD(IntlIterator, current)
 	data = ii->iterator->funcs->get_current_data(ii->iterator);
-	if (data) {
+	if (data && Z_TYPE_P(data) != IS_UNDEF) {
 		ZVAL_COPY_DEREF(return_value, data);
 [2021-11-11 11:18 UTC]
-Package: intl +Package: I18N and L10N related
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 21:01:28 2024 UTC