You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The C implementation of bytearray.take_bytes() reads the size before calling
the argument's __index__(), then uses that stale size for the bounds check and
the buffer reads, so an __index__ that resizes the bytearray reads freed
memory (a use-after-free; segfaults on a debug build).
Bug report
Bug description:
The C implementation of
bytearray.take_bytes()reads the size before callingthe argument's
__index__(), then uses that stale size for the bounds check andthe buffer reads, so an
__index__that resizes the bytearray reads freedmemory (a use-after-free; segfaults on a debug build).
bytearray.__setitem__re-reads the size after__index__(GH-91153).CPython versions tested on:
3.15, 3.16
Operating systems tested on:
macOS
Linked PRs