SIGN IN SIGN UP

gh-143378: Fix use-after-free when BytesIO is concurrently mutated during write operations (GH-143408)

PyObject_GetBuffer() can execute user code (e.g. via __buffer__), which may
close or otherwise mutate a BytesIO object while write() or writelines()
is in progress. This could invalidate the internal buffer and lead to a
use-after-free.

Ensure that PyObject_GetBuffer() is called before validation checks.
Z
zhong committed
6d54b6ac7d5744e1f59d784c8e020d632d2959a3
Parent: dcdb23f
Committed by GitHub <noreply@github.com> on 1/9/2026, 11:50:56 AM