FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158928: Fix overflow in bytearray.__init__ from an iterator by cmaloney · Pull Request #158947 · python/cpython · GitHub

Repository navigation

gh-158928: Fix overflow in bytearray.__init__ from an iterator - #158947

Open
cmaloney wants to merge 3 commits into
python:mainfrom
cmaloney:triage-158928-bytearray-init
Open

cmaloney wants to merge 3 commits into
python:mainfrom
cmaloney:triage-158928-bytearray-init

Conversation

cmaloney commented Oct 7, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Passing an iterator to bytearray.__init__ didn't take into account that iterating that iterator could modify the bytearray position and ob_start. When that happened the iterator would write beyond the end of the allocation.

Update the "enough space" check to account for ob_start. The assignment always included it. Add an assert after append that the offsets line up as expected.

Passing an iterator to `bytearray.__init__` didn't take into account
that iterating that iterator could modify the bytearray position and
`ob_start`. When that happened the iterator would write beyond the end
of the allocation.

Update the "enough space" check to account for `ob_start`. The
assignment always included it. Add an assert after append that the
offsets line up as expected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL