summaryrefslogtreecommitdiff
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
authorJack Diederich <jackdied@gmail.com>2009-04-01 20:26:13 +0000
committerJack Diederich <jackdied@gmail.com>2009-04-01 20:26:13 +0000
commit2ecd3c36b584692f46cddf209f7c09edddd21673 (patch)
tree68375e6f1dfd43d4b306be2c5922b542f8f6f7a2 /Lib/test/test_mmap.py
parentce3d22144781845784d17fa3b4b3e034d2d448f0 (diff)
downloadcpython-git-2ecd3c36b584692f46cddf209f7c09edddd21673.tar.gz
bounds check arguments to mmap.move(). All of them. Really.
fixes crasher on OS X 10.5
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 1a23f2e467..d6c62c192f 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -359,15 +359,22 @@ class MmapTests(unittest.TestCase):
m.move(source, dest, size)
except ValueError:
pass
- self.assertRaises(ValueError, m.move, -1, -1, -1)
- self.assertRaises(ValueError, m.move, -1, -1, 0)
- self.assertRaises(ValueError, m.move, -1, 0, -1)
- self.assertRaises(ValueError, m.move, 0, -1, -1)
- self.assertRaises(ValueError, m.move, -1, 0, 0)
- self.assertRaises(ValueError, m.move, 0, -1, 0)
- self.assertRaises(ValueError, m.move, 0, 0, -1)
+
+ offsets = [(-1, -1, -1), (-1, -1, 0), (-1, 0, -1), (0, -1, -1),
+ (-1, 0, 0), (0, -1, 0), (0, 0, -1)]
+ for source, dest, size in offsets:
+ self.assertRaises(ValueError, m.move, source, dest, size)
+
m.close()
+ m = mmap.mmap(-1, 1) # single byte
+ self.assertRaises(ValueError, m.move, 0, 0, 2)
+ self.assertRaises(ValueError, m.move, 1, 0, 1)
+ self.assertRaises(ValueError, m.move, 0, 1, 1)
+ m.move(0, 0, 1)
+ m.move(0, 0, 0)
+
+
def test_anonymous(self):
# anonymous mmap.mmap(-1, PAGE)
m = mmap.mmap(-1, PAGESIZE)