From 0a1a36b74bdf8da286924a1c9652853b1c46f536 Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 28 Oct 2021 23:02:34 +0800 Subject: bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271) --- Python/ceval.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python') diff --git a/Python/ceval.c b/Python/ceval.c index 4ac0b53dd6..d52ca9c65d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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. */ -- cgit v1.2.1