Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05448a6

Browse files
committed
merge 3.5
2 parents cc554b6 + 5a7d923 commit 05448a6

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

Objects/listobject.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,17 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
634634
item = a->ob_item;
635635
/* recycle the items that we are about to remove */
636636
s = norig * sizeof(PyObject *);
637-
if (s > sizeof(recycle_on_stack)) {
638-
recycle = (PyObject **)PyMem_MALLOC(s);
639-
if (recycle == NULL) {
640-
PyErr_NoMemory();
641-
goto Error;
637+
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
638+
if (s) {
639+
if (s > sizeof(recycle_on_stack)) {
640+
recycle = (PyObject **)PyMem_MALLOC(s);
641+
if (recycle == NULL) {
642+
PyErr_NoMemory();
643+
goto Error;
644+
}
642645
}
646+
memcpy(recycle, &item[ilow], s);
643647
}
644-
memcpy(recycle, &item[ilow], s);
645648

646649
if (d < 0) { /* Delete -d items */
647650
Py_ssize_t tail;

0 commit comments

Comments
 (0)