From e959dd9f5c1d8865d4e10c49eb30ee0a4fe2735d Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 8 Feb 2022 14:22:13 +0900 Subject: [PATCH] bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209) --- Modules/_ctypes/_ctypes.c | 1 + 1 file changed, 1 insertion(+) 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);