Skip to content

Conversation

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jan 9, 2026

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.
(cherry picked from commit 6d54b6a)

Co-authored-by: zhong [email protected]

…ted during write operations (pythonGH-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.
(cherry picked from commit 6d54b6a)

Co-authored-by: zhong <[email protected]>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) January 9, 2026 11:54
@serhiy-storchaka serhiy-storchaka merged commit f264f10 into python:3.14 Jan 9, 2026
49 checks passed
@miss-islington miss-islington deleted the backport-6d54b6a-3.14 branch January 9, 2026 12:16
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.

3 participants