From db052851a70fd95d047c6263fc16a75e4d47b3ed Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 10 Feb 2022 19:10:07 +0900 Subject: [PATCH] bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249) --- Modules/_ctypes/callbacks.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 591b944d76f..6037f5fd842 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