Mercurial > cpython-lru_cache-weakref
diff Modules/arraymodule.c @ 55113:8e8157445a55
Issue 4509: Do not modify an array if we know the change would result
in a failure due to exported buffers.
| author | Alexandre Vassalotti <alexandre@peadrop.com> |
|---|---|
| date | Sun, 05 Jul 2009 05:38:18 +0000 |
| parents | 2df1517d868c |
| children | a76b34cfc897 |
line wrap: on
line diff
--- a/Modules/arraymodule.c Sat Jul 04 15:18:00 2009 +0000 +++ b/Modules/arraymodule.c Sun Jul 05 05:38:18 2009 +0000 @@ -735,6 +735,14 @@ 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,
