summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-05-09 22:27:59 (GMT)
committerGitHub <noreply@github.com>2018-05-09 22:27:59 (GMT)
commit8ac158a6dfb86880e22003afe0ff39ec31b0a094 (patch)
tree0c939d34c76755f0020406e8d096180d70cd38cf /Modules/_ctypes
parentfa40fc0593012893e447875632e9ed3df277561f (diff)
downloadcpython-8ac158a6dfb86880e22003afe0ff39ec31b0a094.zip
cpython-8ac158a6dfb86880e22003afe0ff39ec31b0a094.tar.gz
cpython-8ac158a6dfb86880e22003afe0ff39ec31b0a094.tar.bz2
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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 258e805..2c0a769 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -5327,7 +5327,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, ... */