summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2018-05-09 21:38:56 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2018-05-09 21:38:56 (GMT)
commitd518d8bc8d5dac1a1270612f424d33e0e5afc2b5 (patch)
treeb532e2e0677ccb8106a20e0c10411fc84c1e14c5 /Modules
parent8cf4b34b3665b8bb39ea7111e6b5c3410899d3e4 (diff)
downloadcpython-d518d8bc8d5dac1a1270612f424d33e0e5afc2b5.zip
cpython-d518d8bc8d5dac1a1270612f424d33e0e5afc2b5.tar.gz
cpython-d518d8bc8d5dac1a1270612f424d33e0e5afc2b5.tar.bz2
bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 93e8d8d..5bf49ac 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -5319,7 +5319,7 @@ cast_check_pointertype(PyObject *arg)
if (PyCFuncPtrTypeObject_Check(arg))
return 1;
dict = PyType_stgdict(arg);
- if (dict) {
+ if (dict != NULL && dict->proto != NULL) {
if (PyUnicode_Check(dict->proto)
&& (strchr("sPzUZXO", PyUnicode_AsUTF8(dict->proto)[0]))) {
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */