diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-03-31 10:15:11 -0700 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-03-31 20:15:11 +0300 |
commit | 5e233951d931acc0e927100c51e9a27a2791b6a5 (patch) | |
tree | 23f026fc1b6f76137a7f00dd83619d68b91646ee /Modules | |
parent | 3e78c7c30553baf72b7eb6fe3384d88fff549906 (diff) | |
download | cpython-git-5e233951d931acc0e927100c51e9a27a2791b6a5.tar.gz |
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106) (GH-12642)
(cherry picked from commit 5f2c50810a67982b0c80f6d3258fee3647f67005)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 48ad696e10..be0b321bad 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2663,10 +2663,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)); } |