Skip to content

Commit 620580f

Browse files
committed
Fix refleaks if Py_EnterRecursiveCall() fails
Issue python#29306: Destroy argstuple and kwdict if Py_EnterRecursiveCall() fails.
1 parent 17a63e2 commit 620580f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Objects/abstract.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,14 +2350,15 @@ _PyObject_FastCallDict(PyObject *callable, PyObject **args, Py_ssize_t nargs,
23502350
}
23512351

23522352
if (Py_EnterRecursiveCall(" while calling a Python object")) {
2353+
Py_DECREF(argstuple);
23532354
return NULL;
23542355
}
23552356

23562357
result = (*call)(callable, argstuple, kwargs);
23572358

23582359
Py_LeaveRecursiveCall();
2359-
23602360
Py_DECREF(argstuple);
2361+
23612362
result = _Py_CheckFunctionResult(callable, result, NULL);
23622363
return result;
23632364
}
@@ -2544,6 +2545,8 @@ _PyObject_FastCallKeywords(PyObject *callable, PyObject **stack, Py_ssize_t narg
25442545
}
25452546

25462547
if (Py_EnterRecursiveCall(" while calling a Python object")) {
2548+
Py_DECREF(argstuple);
2549+
Py_XDECREF(kwdict);
25472550
return NULL;
25482551
}
25492552

0 commit comments

Comments
 (0)