Kaydet (Commit) 69c2b883 authored tarafından Guido van Rossum's avatar Guido van Rossum

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
üst 21123ab7
...@@ -154,7 +154,7 @@ mmap_close_method(mmap_object *self, PyObject *args) ...@@ -154,7 +154,7 @@ mmap_close_method(mmap_object *self, PyObject *args)
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
#define CHECK_VALID(err) \ #define CHECK_VALID(err) \
do { \ do { \
if (!self->map_handle) { \ if (self->map_handle == INVALID_HANDLE_VALUE) { \
PyErr_SetString (PyExc_ValueError, "mmap closed or invalid"); \ PyErr_SetString (PyExc_ValueError, "mmap closed or invalid"); \
return err; \ return err; \
} \ } \
...@@ -974,7 +974,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) ...@@ -974,7 +974,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
return NULL; return NULL;
} }
/* Win9x appears to need us seeked to zero */ /* 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); m_obj = PyObject_New (mmap_object, &mmap_object_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment