summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-18 16:38:00 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-18 16:38:00 (GMT)
commit0654ccd1d23986accb99c69e84369b99f9cdc8e2 (patch)
treecb8fb71b6573ef563641d0f27ce4de532edac144 /Modules/mmapmodule.c
parent14d34a0e43ce1b4dba1da50376011cd7a18dba49 (diff)
downloadcpython-0654ccd1d23986accb99c69e84369b99f9cdc8e2.zip
cpython-0654ccd1d23986accb99c69e84369b99f9cdc8e2.tar.gz
cpython-0654ccd1d23986accb99c69e84369b99f9cdc8e2.tar.bz2
Merged revisions 69714,69718 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69714 | hirokazu.yamamoto | 2009-02-17 19:12:10 +0900 | 1 line Issue #5292: Fixed mmap crash on its boundary access m[len(m)]. ........ r69718 | hirokazu.yamamoto | 2009-02-17 22:17:26 +0900 | 3 lines Issue #5282: Fixed mmap resize on 32bit windows and unix. When offset > 0, The file was resized to wrong size. ........
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c8
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;