]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #7788: Fix a crash produced by deleting a list slice with huge
authorMark Dickinson <dickinsm@gmail.com>
Fri, 29 Jan 2010 17:11:39 +0000 (17:11 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Fri, 29 Jan 2010 17:11:39 +0000 (17:11 +0000)
step value.  Patch by Marcin Bachry.

Lib/test/list_tests.py
Lib/test/test_array.py
Lib/test/test_bytes.py
Misc/NEWS
Modules/arraymodule.c
Objects/bytearrayobject.c
Objects/listobject.c

index c9aa3160a9b930a8c0a0b7762c337324bec51269..8dd6de634e25cdf3a862911772dde4e4907ded30 100644 (file)
@@ -519,6 +519,9 @@ class CommonTest(seq_tests.CommonTest):
         a = self.type2test(range(10))
         a[::2] = tuple(range(5))
         self.assertEqual(a, self.type2test([0, 1, 1, 3, 2, 5, 3, 7, 4, 9]))
+        # test issue7788
+        a = self.type2test(range(10))
+        del a[9::1<<333]
 
     def test_constructor_exception_handling(self):
         # Bug #1242657
index dfd0fa4f79fe87e364ab450070dd414e93010d9d..9b289abd089aa306683155641c1bcfdc2949a4d3 100755 (executable)
@@ -882,6 +882,9 @@ class NumberTest(BaseTest):
         a = array.array(self.typecode, range(10))
         del a[::1000]
         self.assertEqual(a, array.array(self.typecode, [1,2,3,4,5,6,7,8,9]))
+        # test issue7788
+        a = array.array(self.typecode, range(10))
+        del a[9::1<<333]
 
     def test_assignment(self):
         a = array.array(self.typecode, range(10))
index aab51da03d0f4264818a045b25b511a9b12bcb25..70cab1c64ee654f1c4f98b724996f249952084cb 100644 (file)
@@ -565,7 +565,7 @@ class ByteArrayTest(BaseBytesTest):
         self.assertEqual(b, bytearray([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9]))
 
     def test_extended_set_del_slice(self):
-        indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
+        indices = (0, None, 1, 3, 19, 300, 1<<333, -1, -2, -31, -300)
         for start in indices:
             for stop in indices:
                 # Skip invalid step 0
index 2bdd5a50a779a7f05bf84928255d4e70ba056c36..e19d902c2a8f118b84a165349d4d99da6a712ebe 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 3?
 Core and Builtins
 -----------------
 
+- Issue #7788: Fix an interpreter crash produced by deleting a list
+  slice with very large step value.
+
 - Issue #7766: Change sys.getwindowsversion() return value to a named
   tuple and add the additional members returned in an OSVERSIONINFOEX
   structure. The new members are service_pack_major, service_pack_minor,
index 018ab873d42457aa10fda8b0f5375b4afcd375d5..c631b618891cebfe81fcead82d99f77b608f5ff5 100644 (file)
@@ -1792,8 +1792,9 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
        }
        else if (needed == 0) {
                /* Delete slice */
-               Py_ssize_t cur, i;
-               
+               size_t cur;
+               Py_ssize_t i;
+
                if (step < 0) {
                        stop = start + 1;
                        start = stop + step * (slicelength - 1) - 1;
index 9d1ef9910d9efa3b437bc5a449cc9eeade4c7229..87c6599df4f0a0270287a952e1ce11746aaa2886 100644 (file)
@@ -691,7 +691,8 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
     else {
         if (needed == 0) {
             /* Delete slice */
-            Py_ssize_t cur, i;
+            size_t cur;
+            Py_ssize_t i;
 
             if (!_canresize(self))
                 return -1;
index dea51ed768a6385f259f45c999098c0ab061fcb2..0e2ce0ad8ee255cc68d9c76ffc1b5fb7718011e7 100644 (file)
@@ -2624,7 +2624,8 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
                if (value == NULL) {
                        /* delete slice */
                        PyObject **garbage;
-                       Py_ssize_t cur, i;
+                       size_t cur;
+                       Py_ssize_t i;
 
                        if (slicelength <= 0)
                                return 0;