Skip to content

Commit 0a1a36b

Browse files
bpo-44525: Add recursive checks for CALL_FUNCTION_BUILTIN_O (GH-29271)
1 parent f291404 commit 0a1a36b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python/ceval.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,8 +4742,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
47424742
STAT_INC(CALL_FUNCTION, hit);
47434743

47444744
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
4745+
// This is slower but CPython promises to check all non-vectorcall
4746+
// function calls.
4747+
if (_Py_EnterRecursiveCall(tstate, " while calling a Python object")) {
4748+
goto error;
4749+
}
47454750
PyObject *arg = POP();
47464751
PyObject *res = cfunc(PyCFunction_GET_SELF(callable), arg);
4752+
_Py_LeaveRecursiveCall(tstate);
47474753
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
47484754

47494755
/* Clear the stack of the function object. */

0 commit comments

Comments
 (0)