From: Benjamin Peterson <benjamin@python.org> Date: Sat, 11 Oct 2014 00:58:30 +0000 (-0400) Subject: prevent passing NULL to memcpy (closes #22605) X-Git-Tag: v3.5.0a1~699^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=682124ccc3c7e07006ca99346f749689a5229459;p=python prevent passing NULL to memcpy (closes #22605) Patch by Jakub Wilk. --- diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 4a1c158514..24f0ea0f9f 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2628,7 +2628,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->allocated = Py_SIZE(self); } } - else if (initial != NULL && array_Check(initial)) { + else if (initial != NULL && array_Check(initial) && len > 0) { arrayobject *self = (arrayobject *)a; arrayobject *other = (arrayobject *)initial; memcpy(self->ob_item, other->ob_item, len * other->ob_descr->itemsize);