Skip to content

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

Open
iliaal wants to merge 1 commit into
masterfrom
fix/iconv-seek-stale-cd-master
Open

iconv: keep working converter when filter seek reset fails#294
iliaal wants to merge 1 commit into
masterfrom
fix/iconv-seek-stale-cd-master

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

php_iconv_stream_filter_seek() assigned the failed iconv_open() result ((iconv_t)-1) to the filter's converter on reset failure, poisoning the filter for every subsequent read/write, and it closed the previous converter before knowing whether a replacement could be opened.

Open the new converter first and only close/replace the old one on success, so a failed reset leaves the filter with its still-working converter. No regression test: an iconv_open() failure mid-seek is not reachable from userland (the filter's charsets are fixed at creation), so this ships as a defensive correctness fix per our test-only-when-triggerable rule. ext/iconv suite 73 tests, 0 failures.

php_iconv_stream_filter_seek() assigned the failed iconv_open() result
((iconv_t)-1) to the filter's converter on reset failure, poisoning it
for every subsequent read/write, and closed the previous converter
before knowing whether a replacement could be opened. Open the new
converter first and only close/replace the old one on success, so a
failed reset leaves the filter with its still-working converter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant