prevent passing NULL to memcpy (closes #22605)

Patch by Jakub Wilk.
This commit is contained in:
Benjamin Peterson 2014-10-10 20:58:30 -04:00
parent ad0c57fed8
commit 682124ccc3
1 changed files with 1 additions and 1 deletions

View File

@ -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);