From: Hirokazu Yamamoto Date: Sun, 14 Jun 2009 03:53:55 +0000 (+0000) Subject: Issue #6271: mmap tried to close invalid file handle (-1) when annonymous. X-Git-Tag: v2.7a1~950 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=983a46543cbf310b5d5915d7bed8e4581cc1507d;p=python Issue #6271: mmap tried to close invalid file handle (-1) when annonymous. (On Unix) Patch by STINNER Victor. --- diff --git a/Misc/NEWS b/Misc/NEWS index 8af9914494..aabdc216db 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 f660d6bb0b..e1970cbb53 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);