Skip to content

iconv: keep working converter when stream filter seek reset fails - #23594

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:promote/iconv-seek-stale-cd
Open

iconv: keep working converter when stream filter seek reset fails#23594
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:promote/iconv-seek-stale-cd

Conversation

@iliaal

@iliaal iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Member

php_iconv_stream_filter_seek() closed the filter's converter before knowing whether a replacement could be opened, then assigned the failed iconv_open() result. That left self->cd as (iconv_t)-1 for every subsequent read and write, and the filter dtor then called iconv_close() on it. Opening the replacement first and swapping it in only on success keeps the working converter on failure.

No test: the charsets are fixed when the filter is created and already validated by the iconv_open() there, so a second open of the same pair can only fail on OOM. There is no userland input that reaches the branch.

php_iconv_stream_filter_seek() closed the filter's converter before
knowing whether a replacement could be opened, then stored the failed
iconv_open() result. That left self->cd as (iconv_t)-1 for every later
read and write, and for the iconv_close() in the filter dtor. Open the
replacement first and only swap it in on success.

Closes phpGH-23594
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