Skip to content

Fix IntlPartsIterator key off-by-one error and first key #8172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented Mar 4, 2022

Closes GH-7734

IntlPartsIterator with PARTS_ITERATOR_KEY_RIGHT relies on advancing the iterator on rewind and setting the index to the start of the next character sequence. However, the engine resets the index to -1 after rewinding the iterator.

iter->index = -1; /* will be set to 0 before using next handler */

This does not happen in iterator_to_array, however.

iter->index = 0;
if (iter->funcs->rewind) {
iter->funcs->rewind(iter);
if (EG(exception)) {
goto done;
}
}
while (iter->funcs->valid(iter) == SUCCESS) {

Which is why this wasn't caught in 0eb5c1a.

IntlIterator_ce_ptr->ce_flags |= ZEND_ACC_REUSE_GET_ITERATOR; will be removed when merging into master since the inheritance mechanism of get_iterator is different there and this part was already fixed (see 0eb5c1a).

@iluuu1994 iluuu1994 changed the title Fix IntlPartsIterator key off-by-one error Fix IntlPartsIterator key off-by-one error and first key Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant