Skip to content

Commit 3478b01

Browse files
committed
bpo-16575: Fix refleak on passing unions in ctypes
The master and 3.8 versions of the previous change work as expected because we perform the lookup for the `from_param` after the union check. However, in 3.7, this lookup happens before the union validation and so we must decrease the reference for `cnv` before returning.
1 parent 1bfc567 commit 3478b01

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,7 @@ converters_from_argtypes(PyObject *ob)
22852285
if (stgdict->flags & TYPEFLAG_HASUNION) {
22862286
Py_DECREF(converters);
22872287
Py_DECREF(ob);
2288+
Py_DECREF(cnv);
22882289
if (!PyErr_Occurred()) {
22892290
PyErr_Format(PyExc_TypeError,
22902291
"item %zd in _argtypes_ passes a union by "

0 commit comments

Comments
 (0)