https://github.com/python/cpython/commit/3f7141dac90d06795293ca2d071198ab6b2318b2
commit: 3f7141dac90d06795293ca2d071198ab6b2318b2
branch: main
author: Pieter Eendebak <[email protected]>
committer: vstinner <[email protected]>
date: 2026-03-10T10:46:13+01:00
summary:
gh-145376: Fix refleaks and double decref for code in Python/ (#145666)
files:
M Python/ceval.c
M Python/crossinterp.c
M Python/sysmodule.c
diff --git a/Python/ceval.c b/Python/ceval.c
index 1e5142f4b456a1..950050a6027116 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2243,6 +2243,7 @@ _PyEval_ExceptionGroupMatch(_PyInterpreterFrame *frame,
PyObject* exc_value,
if (f != NULL) {
PyObject *tb = _PyTraceBack_FromFrame(NULL, f);
if (tb == NULL) {
+ Py_DECREF(wrapped);
return -1;
}
PyException_SetTraceback(wrapped, tb);
diff --git a/Python/crossinterp.c b/Python/crossinterp.c
index c8a80e7a986008..f92927da475321 100644
--- a/Python/crossinterp.c
+++ b/Python/crossinterp.c
@@ -1103,12 +1103,12 @@ _convert_exc_to_TracebackException(PyObject *exc,
PyObject **p_tbexc)
}
PyObject *tbexc = PyObject_Call(create, args, kwargs);
- Py_DECREF(args);
- Py_DECREF(kwargs);
- Py_DECREF(create);
if (tbexc == NULL) {
goto error;
}
+ Py_DECREF(args);
+ Py_DECREF(kwargs);
+ Py_DECREF(create);
*p_tbexc = tbexc;
return 0;
@@ -1497,7 +1497,7 @@ _PyXI_excinfo_Apply(_PyXI_excinfo *info, PyObject
*exctype)
PyObject *formatted = _PyXI_excinfo_format(info);
PyErr_SetObject(exctype, formatted);
- Py_DECREF(formatted);
+ Py_XDECREF(formatted);
if (tbexc != NULL) {
PyObject *exc = PyErr_GetRaisedException();
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 55b4072213d3c2..893a116565e37e 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2499,7 +2499,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject
*script)
}
if (PySys_Audit("sys.remote_exec", "iO", pid, script) < 0) {
- return NULL;
+ goto error;
}
debugger_script_path = PyBytes_AS_STRING(path);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]