]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249)
authorDong-hee Na <donghee.na@python.org>
Thu, 10 Feb 2022 10:10:07 +0000 (19:10 +0900)
committerGitHub <noreply@github.com>
Thu, 10 Feb 2022 10:10:07 +0000 (19:10 +0900)
Modules/_ctypes/callbacks.c

index 591b944d76fcbef77a34646f1fc05ede1dfc345e..6037f5fd842860895b039ce0ec8dcf02f4a0d478 100644 (file)
@@ -165,11 +165,7 @@ static void _CallPythonObject(void *mem,
     assert(PyTuple_Check(converters));
     nargs = PyTuple_GET_SIZE(converters);
     assert(nargs <= CTYPES_MAX_ARGCOUNT);
-    PyObject **args = NULL;
-    if (nargs > 0) {
-        args = alloca(nargs * sizeof(PyObject *));
-    }
-
+    PyObject **args = alloca(nargs * sizeof(PyObject *));
     PyObject **cnvs = PySequence_Fast_ITEMS(converters);
     for (i = 0; i < nargs; i++) {
         PyObject *cnv = cnvs[i]; // borrowed ref