Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:3.15from
serhiy-storchaka:backport-153539-3.15
Open

[3.15] gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder (GH-153540)#156193
serhiy-storchaka wants to merge 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>
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