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