diff options
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 034bd22..7fa1037 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -455,7 +455,7 @@ mmap_resize_method(mmap_object *self, off_lo = (DWORD)(self->offset & 0xFFFFFFFF); #else newSizeHigh = 0; - newSizeLow = (DWORD)new_size; + newSizeLow = (DWORD)(self->offset + new_size); off_hi = 0; off_lo = (DWORD)self->offset; #endif @@ -501,7 +501,7 @@ mmap_resize_method(mmap_object *self, } else { void *newmap; - if (ftruncate(self->fd, new_size) == -1) { + if (ftruncate(self->fd, self->offset + new_size) == -1) { PyErr_SetFromErrno(mmap_module_error); return NULL; } @@ -692,7 +692,7 @@ mmap_subscript(mmap_object *self, PyObject *item) return NULL; if (i < 0) i += self->size; - if (i < 0 || (size_t)i > self->size) { + if (i < 0 || (size_t)i >= self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; @@ -797,7 +797,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value) return -1; if (i < 0) i += self->size; - if (i < 0 || (size_t)i > self->size) { + if (i < 0 || (size_t)i >= self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return -1; |