summaryrefslogtreecommitdiff
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-10-10 20:58:30 -0400
committerBenjamin Peterson <benjamin@python.org>2014-10-10 20:58:30 -0400
commit682124ccc3c7e07006ca99346f749689a5229459 (patch)
tree8e42d17de9846f99287b10a097887460faaa9b02 /Modules/arraymodule.c
parentad0c57fed8ede5b7291d0e401f3595975f5eddad (diff)
downloadcpython-git-682124ccc3c7e07006ca99346f749689a5229459.tar.gz
prevent passing NULL to memcpy (closes #22605)
Patch by Jakub Wilk.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c2
1 files changed, 1 insertions, 1 deletions
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);