From: Neal Norwitz Date: Sun, 5 Feb 2006 06:00:54 +0000 (+0000) Subject: Backport: X-Git-Tag: v2.4.3c1~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b5abd1615376bc7a66a16c5156a3a4cfc89eb54b;p=thirdparty%2FPython%2Fcpython.git Backport: Patch #1407135, bug #1424041: mmap.mmap(-1, size, ...) can return anonymous memory again on Unix. --- diff --git a/Misc/NEWS b/Misc/NEWS index e23712b2ffae..2b1cdbc097b7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -45,6 +45,9 @@ Core and builtins Extension Modules ----------------- +- Patch #1407135, bug #1424041: mmap.mmap(-1, size, ...) can return + anonymous memory again on Unix. + - Bug #1215432: in bsddb DB.associate() would crash when a DBError was supposed to be raised. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 9fd2ca48263c..8dcbe865f332 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -917,12 +917,17 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) m_obj->data = NULL; m_obj->size = (size_t) map_size; m_obj->pos = (size_t) 0; - m_obj->fd = dup(fd); - if (m_obj->fd == -1) { - Py_DECREF(m_obj); - PyErr_SetFromErrno(mmap_module_error); - return NULL; + if (fd == -1) { + m_obj->fd = -1; + } else { + m_obj->fd = dup(fd); + if (m_obj->fd == -1) { + Py_DECREF(m_obj); + PyErr_SetFromErrno(mmap_module_error); + return NULL; + } } + m_obj->data = mmap(NULL, map_size, prot, flags, fd, 0);