]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127945: acquire critical section around `PyCFuncPtr_call` (#131898)
authorKumar Aditya <kumaraditya@python.org>
Sun, 30 Mar 2025 11:01:12 +0000 (16:31 +0530)
committerGitHub <noreply@github.com>
Sun, 30 Mar 2025 11:01:12 +0000 (11:01 +0000)
Modules/_ctypes/_ctypes.c

index 7536d3fdc2b882567f8259a0bfa3c68135a0c775..59ea579627e56ff7487cbafe4048c880f17b0be5 100644 (file)
@@ -4406,7 +4406,7 @@ _build_result(PyObject *result, PyObject *callargs,
 }
 
 static PyObject *
-PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
+PyCFuncPtr_call_lock_held(PyObject *op, PyObject *inargs, PyObject *kwds)
 {
     PyObject *restype;
     PyObject *converters;
@@ -4544,6 +4544,16 @@ PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
                          outmask, inoutmask, numretvals);
 }
 
+static PyObject *
+PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
+{
+    PyObject *result;
+    Py_BEGIN_CRITICAL_SECTION(op);
+    result = PyCFuncPtr_call_lock_held(op, inargs, kwds);
+    Py_END_CRITICAL_SECTION();
+    return result;
+}
+
 static int
 PyCFuncPtr_traverse(PyObject *op, visitproc visit, void *arg)
 {