summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-03-31 16:02:11 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-03-31 16:02:11 (GMT)
commit5f2c50810a67982b0c80f6d3258fee3647f67005 (patch)
tree8877b499bb487855fa8ab8ee8c8528d32d54bb8f /Modules
parent48600c72c1afe1096c2412a135a43f8cdd895195 (diff)
downloadcpython-5f2c50810a67982b0c80f6d3258fee3647f67005.zip
cpython-5f2c50810a67982b0c80f6d3258fee3647f67005.tar.gz
cpython-5f2c50810a67982b0c80f6d3258fee3647f67005.tar.bz2
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 03f8e75..b3a2030 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2743,10 +2743,11 @@ PyCData_reduce(PyObject *myself, PyObject *args)
"ctypes objects containing pointers cannot be pickled");
return NULL;
}
- return Py_BuildValue("O(O(NN))",
- _unpickle,
- Py_TYPE(myself),
- PyObject_GetAttrString(myself, "__dict__"),
+ PyObject *dict = PyObject_GetAttrString(myself, "__dict__");
+ if (dict == NULL) {
+ return NULL;
+ }
+ return Py_BuildValue("O(O(NN))", _unpickle, Py_TYPE(myself), dict,
PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
}