Skip to content

[3.15] gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder (GH-153540) - #156193

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-153539-3.15
Oct 9, 2026
Merged

serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-153539-3.15

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Manual backport of #153540 to 3.15: the cherry-pick did not apply cleanly, because the test file differs.

…entrant decoder (pythonGH-153540)

TextIOWrapper.tell() used a borrowed next_input from the snapshot across the
decoder's getstate/decode/setstate calls, so a decoder that reenters seek()
from getstate could free it and leave tell() reading freed memory. Own the
reference across those calls, matching the sibling textiowrapper_read_chunk.

(cherry picked from commit fa0ec86)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
@serhiy-storchaka
serhiy-storchaka merged commit 6de9200 into python:3.15 Oct 9, 2026
56 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-153539-3.15 branch October 9, 2026 17:56
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.

2 participants