summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-03-31 13:22:01 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-03-31 13:22:01 (GMT)
commit60098040c8a1782f4e68a0833cf351b9b2023162 (patch)
tree589f7a997680694f11415d5406c99f24baaa3bd9 /Lib/test
parent61e9b35e910c57ebf1c3f30f5de05ff7fa327dab (diff)
downloadcpython-60098040c8a1782f4e68a0833cf351b9b2023162.zip
cpython-60098040c8a1782f4e68a0833cf351b9b2023162.tar.gz
cpython-60098040c8a1782f4e68a0833cf351b9b2023162.tar.bz2
Merged revisions 70800 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70800 | hirokazu.yamamoto | 2009-03-31 22:13:05 +0900 | 1 line Issue #5387: Fixed mmap.move crash by integer overflow. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_mmap.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 31daa8d..a73dfed 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -338,6 +338,23 @@ class MmapTests(unittest.TestCase):
mf.close()
f.close()
+ # more excessive test
+ data = "0123456789"
+ for dest in range(len(data)):
+ for src in range(len(data)):
+ for count in range(len(data) - max(dest, src)):
+ expected = data[:dest] + data[src:src+count] + data[dest+count:]
+ m = mmap.mmap(-1, len(data))
+ m[:] = data
+ m.move(dest, src, count)
+ self.assertEqual(m[:], expected)
+ m.close()
+
+ # should not crash
+ m = mmap.mmap(-1, 1)
+ self.assertRaises(ValueError, m.move, 1, 1, -1)
+ m.close()
+
def test_anonymous(self):
# anonymous mmap.mmap(-1, PAGE)
m = mmap.mmap(-1, PAGESIZE)