[issue13013] _ctypes.c: refleak
Meador Inge
report at bugs.python.org
Thu Sep 22 04:30:46 CEST 2011
Meador Inge <meadori at gmail.com> added the comment:
This patch seems reasonable. Upon looking at the code in more
detail, however, I can't see how the error condition that leaks the
reference can ever by triggered. In particular, the following code
from the 'PyCArrayType_from_ctype' function:
if (!PyType_Check(itemtype)) {
PyErr_SetString(PyExc_TypeError,
"Expected a type object");
return NULL;
}
'PyCArrayType_from_ctype' is only called from 'CDataType_repeat'. The
'CDataType_repeat' function is only used to implement the 'sq_repeat'
slot in 'CDataType_as_sequence'. 'CDataType_as_sequence' is used in all
of the implemented ctypes (struct, array, union, simple, ...).
Unless 'PyCArrayType_from_ctype' is called through some other means
(it is public), then 'itemtype' should *always* be a type. Or am
I missing something obvious? So, we could add the decref or just remove
the type check code all together (and make 'PyCArrayType_from_ctype'
private).
----------
nosy: +amaury.forgeotdarc, belopolsky
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13013>
_______________________________________
More information about the Python-bugs-list
mailing list