Fix two crashes on Windows:
- CHECK_VALID() was checking the wrong value for a closed fd
- fseek(&_iob[fileno], ...) doesn't work for fileno >= 20
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index fcec0de..c2c723c 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -154,7 +154,7 @@
#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 @@
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);