diff options
author | Gregory P. Smith <greg@krypto.org> | 2022-04-14 18:26:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 18:26:25 (GMT) |
commit | 861974b514bc15ca1a3021f32a2d381c22f1a971 (patch) | |
tree | d7096c495dad3ff1768fbaf20aeea33d821025a8 | |
parent | 7acedd71dec4e60400c865911e8961dbb49d5597 (diff) | |
download | cpython-861974b514bc15ca1a3021f32a2d381c22f1a971.zip cpython-861974b514bc15ca1a3021f32a2d381c22f1a971.tar.gz cpython-861974b514bc15ca1a3021f32a2d381c22f1a971.tar.bz2 |
gh-89455: Fix an uninitialized bool in exception print context. (#91466)
Fix an uninitialized bool in exception print context.
`struct exception_print_context.need_close` was uninitialized.
Found by oss-fuzz in a test case running under the undefined behavior sanitizer.
https://oss-fuzz.com/testcase-detail/6217746058182656
```
Python/pythonrun.c:1241:28: runtime error: load of value 253, which is not a valid value for type 'bool'
#0 0xbf2203 in print_chained cpython3/Python/pythonrun.c:1241:28
#1 0xbea4bb in print_exception_cause_and_context cpython3/Python/pythonrun.c:1320:19
#2 0xbea4bb in print_exception_recursive cpython3/Python/pythonrun.c:1470:13
#3 0xbe9e39 in _PyErr_Display cpython3/Python/pythonrun.c:1517:9
```
Pretty obvious what the ommission was upon code inspection.
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-04-11-18-44-19.gh-issue-89455.d0qMYd.rst | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-11-18-44-19.gh-issue-89455.d0qMYd.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-11-18-44-19.gh-issue-89455.d0qMYd.rst new file mode 100644 index 0000000..e22b4ac --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-11-18-44-19.gh-issue-89455.d0qMYd.rst @@ -0,0 +1,2 @@ +Fixed an uninitialized bool value in the traceback printing code path that +was introduced by the initial bpo-45292 exception groups work. diff --git a/Python/pythonrun.c b/Python/pythonrun.c index d117b79..e086f0f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1504,6 +1504,7 @@ _PyErr_Display(PyObject *file, PyObject *exception, PyObject *value, PyObject *t struct exception_print_context ctx; ctx.file = file; ctx.exception_group_depth = 0; + ctx.need_close = false; ctx.max_group_width = PyErr_MAX_GROUP_WIDTH; ctx.max_group_depth = PyErr_MAX_GROUP_DEPTH; |