[Python-checkins] bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249)

corona10 webhook-mailer at python.org
Thu Feb 10 05:10:12 EST 2022


https://github.com/python/cpython/commit/db052851a70fd95d047c6263fc16a75e4d47b3ed
commit: db052851a70fd95d047c6263fc16a75e4d47b3ed
branch: main
author: Dong-hee Na <donghee.na at python.org>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-02-10T19:10:07+09:00
summary:

bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249)

files:
M Modules/_ctypes/callbacks.c

diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 591b944d76fcb..6037f5fd84286 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -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



More information about the Python-checkins mailing list