]> granicus.if.org Git - python/commitdiff
Fix two crashes on Windows:
authorGuido van Rossum <guido@python.org>
Wed, 9 Apr 2003 19:31:02 +0000 (19:31 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 9 Apr 2003 19:31:02 +0000 (19:31 +0000)
- CHECK_VALID() was checking the wrong value for a closed fd
- fseek(&_iob[fileno], ...) doesn't work for fileno >= 20

Modules/mmapmodule.c

index fcec0de391000df0682423faabb0a0a374282a30..c2c723c302cb52c769b4acd56704eabf2444b5e9 100644 (file)
@@ -154,7 +154,7 @@ mmap_close_method(mmap_object *self, PyObject *args)
 #ifdef MS_WINDOWS
 #define CHECK_VALID(err)                                               \
 do {                                                                   \
-    if (!self->map_handle) {                                           \
+    if (self->map_handle == INVALID_HANDLE_VALUE) {                                            \
        PyErr_SetString (PyExc_ValueError, "mmap closed or invalid");   \
        return err;                                                     \
     }                                                                  \
@@ -974,7 +974,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
                        return NULL;
                }
                /* Win9x appears to need us seeked to zero */
-               fseek(&_iob[fileno], 0, SEEK_SET);
+               lseek(fileno, 0, SEEK_SET);
        }
 
        m_obj = PyObject_New (mmap_object, &mmap_object_type);