diff Modules/arraymodule.c @ 55124:7bb7758e6d64

Add the fix for issue 4509 to the mapping methods.
author Alexandre Vassalotti <alexandre@peadrop.com>
date Sun, 05 Jul 2009 19:57:00 +0000
parents a76b34cfc897
children 67f5e01d5a6a
line wrap: on
line diff
--- a/Modules/arraymodule.c	Sun Jul 05 10:03:49 2009 +0000
+++ b/Modules/arraymodule.c	Sun Jul 05 19:57:00 2009 +0000
@@ -1699,6 +1699,16 @@
 	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,