mirror of
https://github.com/python/cpython.git
synced 2026-05-06 12:49:07 -04:00
[3.14] gh-145376: Fix various reference leaks (GH-145377) (GH-145712)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fix reference leaks in various unusual error scenarios.
|
||||
@@ -509,6 +509,7 @@ pymain_run_interactive_hook(int *exitcode)
|
||||
}
|
||||
|
||||
if (PySys_Audit("cpython.run_interactivehook", "O", hook) < 0) {
|
||||
Py_DECREF(hook);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1151,6 +1151,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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1759,7 +1759,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();
|
||||
|
||||
Reference in New Issue
Block a user