summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2009-07-05 05:38:18 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2009-07-05 05:38:18 (GMT)
commit7e4f3215db36f6c30cddd0ff160cc05dd26dcefc (patch)
tree04d59f633e6b0f093051903ba4d96af46f313457 /Modules/arraymodule.c
parent200cfd00abd31d40d3f9c4d61ec06b63f3f66170 (diff)
downloadcpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.zip
cpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.tar.gz
cpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.tar.bz2
Issue 4509: Do not modify an array if we know the change would result
in a failure due to exported buffers.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 6dc46ad..256bcd8 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -735,6 +735,14 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
ihigh = Py_SIZE(a);
item = a->ob_item;
d = n - (ihigh-ilow);
+ /* Issue #4509: If the array has exported buffers and the slice
+ assignment would change the size of the array, fail early to make
+ sure we don't modify it. */
+ if (d != 0 && a->ob_exports > 0) {
+ PyErr_SetString(PyExc_BufferError,
+ "cannot resize an array that is exporting buffers");
+ return -1;
+ }
if (d < 0) { /* Delete -d items */
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
item + ihigh*a->ob_descr->itemsize,