mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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. ........
This commit is contained in:
parent
6bf6367b67
commit
16caab00a2
3 changed files with 21 additions and 4 deletions
|
@ -335,6 +335,23 @@ class MmapTests(unittest.TestCase):
|
|||
mf.close()
|
||||
f.close()
|
||||
|
||||
# more excessive test
|
||||
data = b"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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue