diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-05-26 11:39:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-26 11:39:52 -0700 |
commit | e60f6e1864d80d80f8928afadec617d161a64150 (patch) | |
tree | 17dadb90364787399da49fffeb7094dae89a990b /Modules/_ctypes | |
parent | d49862582ed3513debed6e919fd4f92e9d4eebbd (diff) | |
download | cpython-git-e60f6e1864d80d80f8928afadec617d161a64150.tar.gz |
bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859)
(cherry picked from commit d518d8bc8d5dac1a1270612f424d33e0e5afc2b5)
Co-authored-by: Oren Milman <orenmn@gmail.com>
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 66bce151eb..3ae6348fef 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, ... */ |