]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271)
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Thu, 28 Oct 2021 15:02:34 +0000 (23:02 +0800)
committerGitHub <noreply@github.com>
Thu, 28 Oct 2021 15:02:34 +0000 (16:02 +0100)
Python/ceval.c

index 4ac0b53dd6e466abd16bda76d7cd7b292df68d4d..d52ca9c65db22280fccf2e684e69062a8d77cbee 100644 (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. */