Skip to content

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

Merged
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-153539-3.13
Aug 21, 2026
Merged

[3.13] gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder (GH-153540)#156195
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-153539-3.13

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

Manual backport of #153540 to 3.13: the tests for _io.TextIOWrapper are in Lib/test/test_io.py there, not in the Lib/test/test_io package.

…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)
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 21, 2026 15:29
@serhiy-storchaka
serhiy-storchaka merged commit 081e0be into python:3.13 Aug 21, 2026
44 checks passed
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