summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-09-07 00:58:25 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-09-07 00:58:25 (GMT)
commitd4d79003073a70e35fa7fd7f6d0eee7b95b6aed3 (patch)
tree89252d3feb35a1ed504ba1798dd7ac22a65202b1
parentd34677c130cfd801a129dbac5791c9804f441acc (diff)
downloadcpython-d4d79003073a70e35fa7fd7f6d0eee7b95b6aed3.zip
cpython-d4d79003073a70e35fa7fd7f6d0eee7b95b6aed3.tar.gz
cpython-d4d79003073a70e35fa7fd7f6d0eee7b95b6aed3.tar.bz2
make sure to not call memcpy with a NULL second argument
-rw-r--r--Objects/listobject.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c414620..8ee86c6 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -669,14 +669,17 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
item = a->ob_item;
/* recycle the items that we are about to remove */
s = norig * sizeof(PyObject *);
- if (s > sizeof(recycle_on_stack)) {
- recycle = (PyObject **)PyMem_MALLOC(s);
- if (recycle == NULL) {
- PyErr_NoMemory();
- goto Error;
+ /* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
+ if (s) {
+ if (s > sizeof(recycle_on_stack)) {
+ recycle = (PyObject **)PyMem_MALLOC(s);
+ if (recycle == NULL) {
+ PyErr_NoMemory();
+ goto Error;
+ }
}
+ memcpy(recycle, &item[ilow], s);
}
- memcpy(recycle, &item[ilow], s);
if (d < 0) { /* Delete -d items */
memmove(&item[ihigh+d], &item[ihigh],