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

[3.13] gh-152682: Fix NULL dereference on OOM in `symtable_visit_type_param_bound_or_default` (GH-152684) by miss-islington · Pull Request #152697 · python/cpython · GitHub

/ cpython Public

[3.13] gh-152682: Fix NULL dereference on OOM in symtable_visit_type_param_bound_or_default (GH-152684) - #152697

Merged
JelleZijlstra merged 2 commits into
python:3.13from
miss-islington:backport-10ed03e-3.13
Jul 6, 2026
Merged

[3.13] gh-152682: Fix NULL dereference on OOM in symtable_visit_type_param_bound_or_default (GH-152684)#152697
JelleZijlstra merged 2 commits into
python:3.13from
miss-islington:backport-10ed03e-3.13

Conversation

miss-islington commented Jun 30, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

In symtable_visit_type_param_bound_or_default(), when a reserved name
(e.g. __classdict__) is used as a type parameter, PyUnicode_FromFormat()
is called to build the SyntaxError message. If the allocation fails and
returns NULL, the subsequent PyErr_SetObject() and Py_DECREF() calls
would dereference NULL, causing a segfault.

Fix by returning 0 immediately when PyUnicode_FromFormat() returns NULL.
This propagates the MemoryError set by PyUnicode_FromFormat().

The bug was introduced in gh-128632 (commit 891c61c).
(cherry picked from commit 10ed03e)

Co-authored-by: Petr Vaganov petrvaganoff@gmail.com

…param_bound_or_default` (pythonGH-152684)

In `symtable_visit_type_param_bound_or_default()`, when a reserved name
(e.g. `__classdict__`) is used as a type parameter, `PyUnicode_FromFormat()`
is called to build the SyntaxError message. If the allocation fails and
returns NULL, the subsequent `PyErr_SetObject()` and `Py_DECREF()` calls
would dereference NULL, causing a segfault.

Fix by returning 0 immediately when `PyUnicode_FromFormat()` returns NULL.
This propagates the MemoryError set by `PyUnicode_FromFormat()`.

The bug was introduced in pythongh-128632 (commit 891c61c).
(cherry picked from commit 10ed03e)

Co-authored-by: Petr Vaganov <petrvaganoff@gmail.com>

read-the-docs-community Bot commented Jun 30, 2026
edited
Loading

Copy link
Copy Markdown

StanFromIreland disabled auto-merge June 30, 2026 15:08

Copy link
Copy Markdown
Member

Disabling till #152684 (comment) is decided.

Copy link
Copy Markdown
Contributor

It seems ready to merge, the same code already in main.

And other backports too:

#152695
#152696

JelleZijlstra merged commit eca0efe into python:3.13 Jul 6, 2026
41 checks passed
miss-islington deleted the backport-10ed03e-3.13 branch July 6, 2026 16:36
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL