Skip to content

Stop grapheme_strrev from using UBRK_DONE as a byte index - #23323

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/intl-grapheme-strrev-ubrk-done
Open

Stop grapheme_strrev from using UBRK_DONE as a byte index#23323
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/intl-grapheme-strrev-ubrk-done

Conversation

@iliaal

@iliaal iliaal commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

grapheme_strrev() called ubrk_previous() inside a loop whose condition still saw the previous position, so UBRK_DONE (-1) was used as a byte offset and overwrote the result NUL. Stop when the iterator is done, and NUL-terminate the zend_string_alloc() buffer.

ubrk_previous() returns UBRK_DONE after the first boundary. The loop
condition ran before that assignment, so the body treated -1 as an
offset and wrote into the zend_string NUL. Break when the iterator is
done, and NUL-terminate the result of zend_string_alloc.
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.

2 participants