diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-09-07 23:31:39 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-09-07 23:31:39 (GMT) |
commit | 1c748f383033df1126f2f79f051eee440ba08449 (patch) | |
tree | dcb41f4507ff7d705cee8e6e8568da2798fa9807 /Modules/_ctypes | |
parent | f3b5bcafcb75a2e350aa447ec7ad3d77a3eaee80 (diff) | |
parent | be8da9c9906571698fe218da9e218ece500d5239 (diff) | |
download | cpython-1c748f383033df1126f2f79f051eee440ba08449.zip cpython-1c748f383033df1126f2f79f051eee440ba08449.tar.gz cpython-1c748f383033df1126f2f79f051eee440ba08449.tar.bz2 |
Issue #27570: Merge null pointer fixes from 3.5
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 6 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f840729..b3a9581 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1375,8 +1375,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) goto error; } stgdict->shape[0] = length; - memmove(&stgdict->shape[1], itemdict->shape, - sizeof(Py_ssize_t) * (stgdict->ndim - 1)); + if (stgdict->ndim > 1) { + memmove(&stgdict->shape[1], itemdict->shape, + sizeof(Py_ssize_t) * (stgdict->ndim - 1)); + } itemsize = itemdict->size; if (length * itemsize < 0) { diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 879afb8..6c0fda9 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -391,9 +391,11 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct } memset(stgdict->ffi_type_pointer.elements, 0, sizeof(ffi_type *) * (basedict->length + len + 1)); - memcpy(stgdict->ffi_type_pointer.elements, - basedict->ffi_type_pointer.elements, - sizeof(ffi_type *) * (basedict->length)); + if (basedict->length > 0) { + memcpy(stgdict->ffi_type_pointer.elements, + basedict->ffi_type_pointer.elements, + sizeof(ffi_type *) * (basedict->length)); + } ffi_ofs = basedict->length; } else { offset = 0; |