From: Benjamin Peterson Date: Wed, 7 Sep 2016 00:58:25 +0000 (-0700) Subject: make sure to not call memcpy with a NULL second argument X-Git-Tag: v3.6.0b1~374^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a7d923e7561d6e2bd8ad505178efa2d27ebd785;p=thirdparty%2FPython%2Fcpython.git make sure to not call memcpy with a NULL second argument --- diff --git a/Objects/listobject.c b/Objects/listobject.c index d688179d6b4d..815a1b9ea2d8 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;