]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- #128713 - mmapmodule.c - type(mmap_object) blew up on Linux.
authorMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 13:23:19 +0000 (13:23 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Sat, 31 Mar 2001 13:23:19 +0000 (13:23 +0000)
- mmap on windows creates a mapping without a name when tagname isn't
  specified

Modules/mmapmodule.c

index b245c895d6e5611967f236794fda6a7735ff40a3..36bc4b709f40a9de706af66aa8c58d2d959d3444 100644 (file)
@@ -841,9 +841,6 @@ new_mmap_object(PyObject *self, PyObject *args)
        int fileno;
        HANDLE fh = 0;
 
-       /* Patch the object type */
-       mmap_object_type.ob_type = &PyType_Type;
-
        if (!PyArg_ParseTuple(args,
                          "iO|z",
                          &fileno,
@@ -907,7 +904,7 @@ new_mmap_object(PyObject *self, PyObject *args)
        m_obj->pos = (size_t) 0;
 
        /* set the tag name */
-       if (tagname != NULL) {
+       if (tagname != NULL && *tagname != '\0') {
                m_obj->tagname = PyMem_Malloc(strlen(tagname)+1);
                if (m_obj->tagname == NULL) {
                        PyErr_NoMemory();
@@ -924,7 +921,7 @@ new_mmap_object(PyObject *self, PyObject *args)
                                               PAGE_READWRITE,
                                               0,
                                               m_obj->size,
-                                              tagname);
+                                              m_obj->tagname);
        if (m_obj->map_handle != NULL) {
                m_obj->data = (char *) MapViewOfFile (m_obj->map_handle,
                                                      FILE_MAP_WRITE,
@@ -962,6 +959,10 @@ extern void
 initmmap(void)
 {
        PyObject *dict, *module;
+
+       /* Patch the object type */
+       mmap_object_type.ob_type = &PyType_Type;
+
        module = Py_InitModule ("mmap", mmap_functions);
        dict = PyModule_GetDict (module);
        mmap_module_error = PyExc_EnvironmentError;