make sure to not call memcpy with a NULL second argument
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 @@
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],