Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
gpshead committed Apr 13, 2022
commit 40c65a324bee569e51fa4d3c621578d9b18dda7f
1 change: 1 addition & 0 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down