cpython/Modules/_io
Cody Maloney db4b1948bc
gh-143008: Fix Null pointer dereferences in TextIOWrapper underlying stream access (#145957)
TextIOWrapper keeps its underlying stream in a member called
`self->buffer`. That stream can be detached by user code, such as custom
`.flush` implementations resulting in `self->buffer` being set to NULL.
The implementation often checked at the start of functions if
`self->buffer` is in a good state, but did not always recheck after
other Python code was called which could modify `self->buffer`.

The cases which need to be re-checked are hard to spot so rather than
rely on reviewer effort create better safety by making all self->buffer
access go through helper functions.

Thank you yihong0618 for the test, NEWS and initial implementation in
gh-143041.

Co-authored-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-09 12:31:44 +02:00
..
clinic gh-143008: Fix Null pointer dereferences in TextIOWrapper underlying stream access (#145957) 2026-06-09 12:31:44 +02:00
_iomodule.c gh-150285: Fix too long docstrings in the io module (GH-150287) 2026-05-24 15:02:21 +03:00
_iomodule.h gh-141376: Fix exported symbols (GH-141377) 2025-11-11 09:21:24 +01:00
bufferedio.c gh-149816: add missing critical section on self in buffered_iternext (#150295) 2026-05-23 08:57:13 +00:00
bytesio.c gh-150285: Fix too long docstrings in the io module (GH-150287) 2026-05-24 15:02:21 +03:00
fileio.c gh-150285: Fix too long docstrings in the io module (GH-150287) 2026-05-24 15:02:21 +03:00
iobase.c gh-150285: Fix too long docstrings in the io module (GH-150287) 2026-05-24 15:02:21 +03:00
stringio.c gh-149046: fix: correctly handle str subclasses in io.StringIO (#149047) 2026-06-01 13:01:57 +00:00
textio.c gh-143008: Fix Null pointer dereferences in TextIOWrapper underlying stream access (#145957) 2026-06-09 12:31:44 +02:00
winconsoleio.c gh-150285: Fix too long docstrings in the io module (GH-150287) 2026-05-24 15:02:21 +03:00