]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 5 Feb 2006 06:00:54 +0000 (06:00 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 5 Feb 2006 06:00:54 +0000 (06:00 +0000)
  Patch #1407135, bug #1424041: mmap.mmap(-1, size, ...) can return
  anonymous memory again on Unix.

Misc/NEWS
Modules/mmapmodule.c

index e23712b2ffaefc79b938157840952914c1a03d80..2b1cdbc097b711e1845e862a0a08f9d4b055f6e8 100644 (file)
--- 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.
 
index 9fd2ca48263c3696039fe265fbcaa79c7a670e04..8dcbe865f332e89bf5af16ee0e8d9e0e0c16fe87 100644 (file)
@@ -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);