Commit daf5d25a authored by Benjamin Peterson's avatar Benjamin Peterson

prevent passing NULL to memcpy (closes #22605)

Patch by Jakub Wilk.
parent cb1a86f1
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment