summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-18 15:11:55 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-18 15:11:55 (GMT)
commit978bacdd305c1fc73ec2cc91adaeba072fe967ae (patch)
treeb143318ef162e36efbe5b52cd8bdc38d2a4ac3f5 /Modules
parent2190ed9d9866850b5622cfa2c5ccdb536fe89ad6 (diff)
downloadcpython-978bacdd305c1fc73ec2cc91adaeba072fe967ae.zip
cpython-978bacdd305c1fc73ec2cc91adaeba072fe967ae.tar.gz
cpython-978bacdd305c1fc73ec2cc91adaeba072fe967ae.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')
-rw-r--r--Modules/mmapmodule.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index a03957c..fad60d1 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -444,7 +444,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
@@ -490,7 +490,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;
}
@@ -731,7 +731,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;
@@ -872,7 +872,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;