]> granicus.if.org Git - python/commitdiff
Issue #6271: mmap tried to close invalid file handle (-1) when annonymous.
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 14 Jun 2009 03:53:55 +0000 (03:53 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 14 Jun 2009 03:53:55 +0000 (03:53 +0000)
(On Unix) Patch by STINNER Victor.

Misc/NEWS
Modules/mmapmodule.c

index 8af991449415fca37897074b36c5ea9f7998f20d..aabdc216dbaa5dbe3c8d5eb317a3ebc38d8a3713 100644 (file)
--- 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.
index f660d6bb0ba2f138b1a647543648e2a1dc5b9659..e1970cbb53be36d3b3eda6713d17acfb4ad260d9 100644 (file)
@@ -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);