Skip to content

Commit

Permalink
bpo-44525: Add recursive checks for CALL_FUNCTION_BUILTIN_O (GH-29271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner authored Oct 28, 2021
1 parent f291404 commit 0a1a36b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4742,8 +4742,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
STAT_INC(CALL_FUNCTION, hit);

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

/* Clear the stack of the function object. */
Expand Down

0 comments on commit 0a1a36b

Please sign in to comment.