]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209)
authorDong-hee Na <donghee.na@python.org>
Tue, 8 Feb 2022 05:22:13 +0000 (14:22 +0900)
committerGitHub <noreply@github.com>
Tue, 8 Feb 2022 05:22:13 +0000 (14:22 +0900)
Modules/_ctypes/_ctypes.c

index da9dd096c73d89bdcd2d1db8a4212b38d56016ec..15eb7521baa1c1ad7d99a2bc129dc2e8acce989e 100644 (file)
@@ -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);