diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2009-07-05 19:57:00 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2009-07-05 19:57:00 (GMT) |
commit | 47137250ff31b8688ea1d988f993ac5fa57b5cc7 (patch) | |
tree | a1ad3f30a930319013bfcff599e6c389c825bdc2 /Modules | |
parent | 1d2e8b90ccfb4a787bbe7e00af402e77e45c09ff (diff) | |
download | cpython-47137250ff31b8688ea1d988f993ac5fa57b5cc7.zip cpython-47137250ff31b8688ea1d988f993ac5fa57b5cc7.tar.gz cpython-47137250ff31b8688ea1d988f993ac5fa57b5cc7.tar.bz2 |
Add the fix for issue 4509 to the mapping methods.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/arraymodule.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 1dbe918..8f6ca39 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1699,6 +1699,16 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) if ((step > 0 && stop < start) || (step < 0 && stop > start)) stop = start; + + /* 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 ((needed == 0 || slicelength != needed) && self->ob_exports > 0) { + PyErr_SetString(PyExc_BufferError, + "cannot resize an array that is exporting buffers"); + return -1; + } + if (step == 1) { if (slicelength > needed) { memmove(self->ob_item + (start + needed) * itemsize, |