mirror of https://github.com/python/cpython
SF #665913, Fix mmap module core dump with unix
Closing an mmap'ed file (calling munmap) twice on Solaris caused a core dump. Will backport.
This commit is contained in:
parent
e7a161e60c
commit
e604c02a80
|
@ -297,6 +297,24 @@ def test_both():
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
# make sure a double close doesn't crash on Solaris (Bug# 665913)
|
||||
f = open(TESTFN, 'w+')
|
||||
|
||||
try: # unlink TESTFN no matter what
|
||||
f.write(2**24 * 'a') # Arbitrary character
|
||||
f.close()
|
||||
|
||||
f = open(TESTFN)
|
||||
mf = mmap.mmap(f.fileno(), 2**24, access=mmap.ACCESS_READ)
|
||||
mf.close()
|
||||
mf.close()
|
||||
f.close()
|
||||
|
||||
finally:
|
||||
try:
|
||||
os.unlink(TESTFN)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
print ' Test passed'
|
||||
|
|
|
@ -141,8 +141,10 @@ mmap_close_method(mmap_object *self, PyObject *args)
|
|||
#endif /* MS_WINDOWS */
|
||||
|
||||
#ifdef UNIX
|
||||
if (self->data != NULL) {
|
||||
munmap(self->data, self->size);
|
||||
self->data = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
|
|
Loading…
Reference in New Issue