Commit f54773f
committed
gh-148798: fix crash in _interpreters.create on surrogate str in config
_config_dict_copy_str passed the result of PyUnicode_AsUTF8 straight to
strncpy. When the string contained an unpaired surrogate, PyUnicode_AsUTF8
returned NULL and set UnicodeEncodeError, and strncpy dereferenced NULL.
Check the return value and propagate the error, mirroring the pattern used
at Modules/_interpretersmodule.c:425.
Add a regression test alongside the existing gh-126221 case.1 parent a00b24e commit f54773f
File tree
3 files changed
+23
-1
lines changed- Lib/test/test_interpreters
- Misc/NEWS.d/next/Core_and_Builtins
- Python
3 files changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
0 commit comments