bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209)

This commit is contained in:
Dong-hee Na 2022-02-08 14:22:13 +09:00 committed by GitHub
parent da576e0829
commit e959dd9f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -2392,6 +2392,7 @@ converters_from_argtypes(PyObject *ob)
Py_ssize_t nArgs = PyTuple_GET_SIZE(ob); Py_ssize_t nArgs = PyTuple_GET_SIZE(ob);
if (nArgs > CTYPES_MAX_ARGCOUNT) { if (nArgs > CTYPES_MAX_ARGCOUNT) {
Py_DECREF(ob);
PyErr_Format(PyExc_ArgError, PyErr_Format(PyExc_ArgError,
"_argtypes_ has too many arguments (%zi), maximum is %i", "_argtypes_ has too many arguments (%zi), maximum is %i",
nArgs, CTYPES_MAX_ARGCOUNT); nArgs, CTYPES_MAX_ARGCOUNT);