summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-07-29 14:35:04 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-07-29 14:35:04 (GMT)
commit56796f672fb571d80199cf08aa059db9df55257b (patch)
tree36db817cd703a8c79f44d96f678ed6ba1e399d13 /Modules
parent085358a3e208b4825dafa829798cfc125f56a2e4 (diff)
downloadcpython-56796f672fb571d80199cf08aa059db9df55257b.zip
cpython-56796f672fb571d80199cf08aa059db9df55257b.tar.gz
cpython-56796f672fb571d80199cf08aa059db9df55257b.tar.bz2
Fix for
[ 587875 ] crash on deleting extended slice The array code got simpler, always a good thing!
Diffstat (limited to 'Modules')
-rw-r--r--Modules/arraymodule.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 8a79027..e757d9f 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1564,7 +1564,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (value == NULL) {
/* delete slice */
- int cur, i;
+ int cur, i, extra;
if (slicelength <= 0)
return 0;
@@ -1575,16 +1575,17 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
step = -step;
}
- for (cur = start, i = 0; cur < stop;
+ for (cur = start, i = 0; i < slicelength - 1;
cur += step, i++) {
memmove(self->ob_item + (cur - i)*itemsize,
self->ob_item + (cur + 1)*itemsize,
(step - 1) * itemsize);
}
- if (self->ob_size > (start + slicelength*step)) {
- memmove(self->ob_item + (start + slicelength*(step - 1))*itemsize,
- self->ob_item + (start + slicelength*step)*itemsize,
- (self->ob_size - (start + slicelength*step))*itemsize);
+ extra = self->ob_size - (cur + 1);
+ if (extra > 0) {
+ memmove(self->ob_item + (cur - i)*itemsize,
+ self->ob_item + (cur + 1)*itemsize,
+ extra*itemsize);
}
self->ob_size -= slicelength;