summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-09-07 00:58:44 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-09-07 00:58:44 (GMT)
commit05448a62ae714d6ca988434d5389db619d96fe07 (patch)
treed9cf1f923f78ede47eec105784e2391fc8dc715a /Objects
parentcc554b65f18d7585203e5f225cfcbe3c04f1359b (diff)
parent5a7d923e7561d6e2bd8ad505178efa2d27ebd785 (diff)
downloadcpython-05448a62ae714d6ca988434d5389db619d96fe07.zip
cpython-05448a62ae714d6ca988434d5389db619d96fe07.tar.gz
cpython-05448a62ae714d6ca988434d5389db619d96fe07.tar.bz2
merge 3.5
Diffstat (limited to 'Objects')
-rw-r--r--Objects/listobject.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 35a49da..90bbf2a 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -634,14 +634,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 */
Py_ssize_t tail;