Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix reference leaks in various unusual error scenarios.
1 change: 1 addition & 0 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ pymain_run_interactive_hook(int *exitcode)
}

if (PySys_Audit("cpython.run_interactivehook", "O", hook) < 0) {
Py_DECREF(hook);
goto error;
}

Expand Down
1 change: 1 addition & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ check_missing___main___attr(PyObject *exc)
// Get the error message.
PyObject *args = PyException_GetArgs(exc);
if (args == NULL || args == Py_None || PyObject_Size(args) < 1) {
Py_XDECREF(args);
assert(!PyErr_Occurred());
return 0;
}
Comment on lines 611 to 615
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (args == NULL || args == Py_None || PyObject_Size(args) < 1) {
Py_XDECREF(args);
assert(!PyErr_Occurred());
return 0;
}
if (args == NULL || args == Py_None) {
assert(!PyErr_Occurred());
return 0;
}
if (PyObject_Size(args) < 1) {
Py_DECREF(args);
assert(!PyErr_Occurred());
return 0;
}

Wouldn't it better be to separate these two cases?

Expand Down
1 change: 1 addition & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -5638,6 +5638,7 @@ _imp__set_lazy_attributes_impl(PyObject *module, PyObject *modobj,

module_dict = get_mod_dict(modobj);
if (module_dict == NULL || !PyDict_CheckExact(module_dict)) {
Py_DECREF(lazy_submodules);
goto done;
}

Expand Down
1 change: 1 addition & 0 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
"traceback",
"_print_exception_bltin");
if (print_exception_fn == NULL || !PyCallable_Check(print_exception_fn)) {
Py_XDECREF(print_exception_fn);
goto fallback;
}

Expand Down
2 changes: 1 addition & 1 deletion Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ sys_getwindowsversion_impl(PyObject *module)
PyObject *realVersion = _sys_getwindowsversion_from_kernel32();
if (!realVersion) {
if (!PyErr_ExceptionMatches(PyExc_WindowsError)) {
return NULL;
goto error;
}

PyErr_Clear();
Expand Down
Loading