From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:02:34 +0000 (+0800) Subject: bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271) X-Git-Tag: v3.11.0a2~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a1a36b74bdf8da286924a1c9652853b1c46f536;p=thirdparty%2FPython%2Fcpython.git bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271) --- diff --git a/Python/ceval.c b/Python/ceval.c index 4ac0b53dd6e4..d52ca9c65db2 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. */