Skip to content

Commit 3f7141d

Browse files
authored
gh-145376: Fix refleaks and double decref for code in Python/ (#145666)
1 parent 19676e5 commit 3f7141d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Python/ceval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,7 @@ _PyEval_ExceptionGroupMatch(_PyInterpreterFrame *frame, PyObject* exc_value,
22432243
if (f != NULL) {
22442244
PyObject *tb = _PyTraceBack_FromFrame(NULL, f);
22452245
if (tb == NULL) {
2246+
Py_DECREF(wrapped);
22462247
return -1;
22472248
}
22482249
PyException_SetTraceback(wrapped, tb);

Python/crossinterp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,12 +1103,12 @@ _convert_exc_to_TracebackException(PyObject *exc, PyObject **p_tbexc)
11031103
}
11041104

11051105
PyObject *tbexc = PyObject_Call(create, args, kwargs);
1106-
Py_DECREF(args);
1107-
Py_DECREF(kwargs);
1108-
Py_DECREF(create);
11091106
if (tbexc == NULL) {
11101107
goto error;
11111108
}
1109+
Py_DECREF(args);
1110+
Py_DECREF(kwargs);
1111+
Py_DECREF(create);
11121112

11131113
*p_tbexc = tbexc;
11141114
return 0;
@@ -1497,7 +1497,7 @@ _PyXI_excinfo_Apply(_PyXI_excinfo *info, PyObject *exctype)
14971497

14981498
PyObject *formatted = _PyXI_excinfo_format(info);
14991499
PyErr_SetObject(exctype, formatted);
1500-
Py_DECREF(formatted);
1500+
Py_XDECREF(formatted);
15011501

15021502
if (tbexc != NULL) {
15031503
PyObject *exc = PyErr_GetRaisedException();

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2499,7 +2499,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
24992499
}
25002500

25012501
if (PySys_Audit("sys.remote_exec", "iO", pid, script) < 0) {
2502-
return NULL;
2502+
goto error;
25032503
}
25042504

25052505
debugger_script_path = PyBytes_AS_STRING(path);

0 commit comments

Comments
 (0)