[issue21983] segfault in ctypes.cast
eryksun
report at bugs.python.org
Tue Jul 15 02:15:55 CEST 2014
eryksun added the comment:
You need to cast to a pointer type, i.e. POINTER(Struct). Trying to cast to just Struct should raise a TypeError. Instead this revealed a bug in cast_check_pointertype (3.4.1):
http://hg.python.org/cpython/file/c0e311e010fc/Modules/_ctypes/_ctypes.c#l5225
dict->proto is NULL in the Struct type's stgdict, so PyUnicode_Check(dict->proto) segfaults. A simple fix is to add a check for this on line 5235:
if (dict && dict->proto) {
Then cast will raise the expected TypeError from line 5242 on return from line 5255.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21983>
_______________________________________
More information about the Python-bugs-list
mailing list