From: Dong-hee Na Date: Thu, 10 Feb 2022 10:10:07 +0000 (+0900) Subject: bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249) X-Git-Tag: v3.11.0a6~250 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db052851a70fd95d047c6263fc16a75e4d47b3ed;p=thirdparty%2FPython%2Fcpython.git bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249) --- diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 591b944d76fc..6037f5fd8428 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