From 3d8827dab67799ab624c22fa27fa423cb14ace27 Mon Sep 17 00:00:00 2001 From: Hirokazu Yamamoto Date: Sun, 14 Jun 2009 04:58:16 +0000 Subject: Merged revisions 73425 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r73425 | hirokazu.yamamoto | 2009-06-14 12:53:55 +0900 | 2 lines Issue #6271: mmap tried to close invalid file handle (-1) when annonymous. (On Unix) Patch by STINNER Victor. ........ --- Misc/NEWS | 3 +++ Modules/mmapmodule.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 9ed8b16..407681b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,9 @@ Core and Builtins Library ------- +- Issue #6271: mmap tried to close invalid file handle (-1) when annonymous. + (On Unix) + What's New in Python 3.1 Release Candidate 2? ============================================= diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index fd247ab..37584e2 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -164,7 +164,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); -- cgit v0.12