]> granicus.if.org Git - python/commitdiff
prevent passing NULL to memcpy (closes #22605)
authorBenjamin Peterson <benjamin@python.org>
Sat, 11 Oct 2014 00:58:30 +0000 (20:58 -0400)
committerBenjamin Peterson <benjamin@python.org>
Sat, 11 Oct 2014 00:58:30 +0000 (20:58 -0400)
Patch by Jakub Wilk.

Modules/arraymodule.c

index 4a1c158514de5c900655d31becee6ef8c3bd28d5..24f0ea0f9f8b0ad470eb3b2da3caa1dee684dfbf 100644 (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);