Commit 10ed03e
authored
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).
1 parent 2303eea commit 10ed03e
3 files changed
Lines changed: 23 additions & 0 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Python
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2861 | 2861 | | |
2862 | 2862 | | |
2863 | 2863 | | |
| 2864 | + | |
2864 | 2865 | | |
2865 | 2866 | | |
2866 | 2867 | | |
| |||
3201 | 3202 | | |
3202 | 3203 | | |
3203 | 3204 | | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
3204 | 3221 | | |
3205 | 3222 | | |
3206 | 3223 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2678 | 2678 | | |
2679 | 2679 | | |
2680 | 2680 | | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
2681 | 2684 | | |
2682 | 2685 | | |
2683 | 2686 | | |
| |||
0 commit comments