bpo-44525: Add recursive checks for CALL_FUNCTION_BUILTIN_O (GH-29271)

This commit is contained in:
Ken Jin 2021-10-28 23:02:34 +08:00 committed by GitHub
parent f291404a80
commit 0a1a36b74b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4742,8 +4742,14 @@ check_eval_breaker:
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. */