Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ

Thanks to Thomas Herve for the fix.
This commit is contained in:
Christian Heimes 2008-02-15 08:20:11 +00:00
parent 2f0da53d28
commit 7adfad850a
3 changed files with 13 additions and 0 deletions

View file

@ -426,6 +426,13 @@ class MmapTests(unittest.TestCase):
return mmap.mmap.__new__(klass, -1, *args, **kwargs)
anon_mmap(PAGESIZE)
def test_prot_readonly(self):
mapsize = 10
open(TESTFN, "wb").write("a"*mapsize)
f = open(TESTFN, "rb")
m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
self.assertRaises(TypeError, m.write, "foo")
def test_main():
run_unittest(MmapTests)