gh-145376: Fix refleaks and double decref for code in Python/ (#145666)

This commit is contained in:
Pieter Eendebak 2026-03-10 10:46:13 +01:00 committed by GitHub
parent 19676e5fc2
commit 3f7141dac9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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);