From: Dong-hee Na Date: Tue, 8 Feb 2022 05:22:13 +0000 (+0900) Subject: bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209) X-Git-Tag: v3.11.0a6~275 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e959dd9f5c1d8865d4e10c49eb30ee0a4fe2735d;p=thirdparty%2FPython%2Fcpython.git bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209) --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index da9dd096c73d..15eb7521baa1 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2392,6 +2392,7 @@ converters_from_argtypes(PyObject *ob) Py_ssize_t nArgs = PyTuple_GET_SIZE(ob); if (nArgs > CTYPES_MAX_ARGCOUNT) { + Py_DECREF(ob); PyErr_Format(PyExc_ArgError, "_argtypes_ has too many arguments (%zi), maximum is %i", nArgs, CTYPES_MAX_ARGCOUNT);