gh-153981: Fix use after free bug itertools.count()#153983
Open
johng wants to merge 4 commits into
python:mainpython/cpython:mainfrom
johng:use-after-free-iter-toolsjohng/cpython:use-after-free-iter-toolsCopy head branch name to clipboard
Open
gh-153981: Fix use after free bug itertools.count()#153983johng wants to merge 4 commits intopython:mainpython/cpython:mainfrom johng:use-after-free-iter-toolsjohng/cpython:use-after-free-iter-toolsCopy head branch name to clipboard
johng wants to merge 4 commits into
python:mainpython/cpython:mainfrom
johng:use-after-free-iter-toolsjohng/cpython:use-after-free-iter-toolsCopy head branch name to clipboard
Conversation
johng
force-pushed
the
use-after-free-iter-tools
branch
from
July 18, 2026 14:40
8623456 to
765d7d5
Compare
Obtain a reference to lz->long_cnt, lz->long_step such that we don't hit a use after free
johng
force-pushed
the
use-after-free-iter-tools
branch
from
July 18, 2026 14:42
765d7d5 to
8580b6a
Compare
Contributor
Author
|
This appears to add some very slight overhead to repr in slow mode, no impact to the likely more heavily used fast mode |
picnixz
reviewed
Jul 24, 2026
| if (lz->long_cnt == NULL) { | ||
| PyObject *long_cnt, *long_step, *result; | ||
|
|
||
| Py_BEGIN_CRITICAL_SECTION(lz); |
Member
There was a problem hiding this comment.
I would suggest uaimg PyUnicodeWriter to avoid all those ifs that are a bit unreadable. It is slightly slower but I thimk it is fine.
Member
|
Performances are not really inportant for |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Obtain a reference to lz->long_cnt, lz->long_step
such that we don't hit a use after free.