summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-06-14 03:53:55 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-06-14 03:53:55 (GMT)
commit983a46543cbf310b5d5915d7bed8e4581cc1507d (patch)
tree2b44fa268455bd7f5fc487e5e2f5a830b12efb35
parente69041db56e42ab1c47188e427acc232d9f4fcea (diff)
downloadcpython-983a46543cbf310b5d5915d7bed8e4581cc1507d.zip
cpython-983a46543cbf310b5d5915d7bed8e4581cc1507d.tar.gz
cpython-983a46543cbf310b5d5915d7bed8e4581cc1507d.tar.bz2
Issue #6271: mmap tried to close invalid file handle (-1) when annonymous.
(On Unix) Patch by STINNER Victor.
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/mmapmodule.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 8af9914..aabdc21 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -325,6 +325,9 @@ Core and Builtins
Library
-------
+- Issue #6271: mmap tried to close invalid file handle (-1) when annonymous.
+ (On Unix)
+
- Issue #6215: All bug fixes and enhancements from the Python 3.1 io library
(including the fast C implementation) have been backported to the standard
``io`` module.
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index f660d6b..e1970cb 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -158,7 +158,8 @@ mmap_close_method(mmap_object *self, PyObject *unused)
#endif /* MS_WINDOWS */
#ifdef UNIX
- (void) close(self->fd);
+ if (0 <= self->fd)
+ (void) close(self->fd);
self->fd = -1;
if (self->data != NULL) {
munmap(self->data, self->size);