diff options
author | Georg Brandl <georg@python.org> | 2005-08-24 07:17:40 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2005-08-24 07:17:40 (GMT) |
commit | 38387b8b910beeea9c6c2ed6c7b1bd26724bd813 (patch) | |
tree | 2dd64e20abe6477fa895c7ca8cd9acd086725203 /Modules | |
parent | 76fb6d84d08c636a51073c5a51b93db14b06555e (diff) | |
download | cpython-38387b8b910beeea9c6c2ed6c7b1bd26724bd813.zip cpython-38387b8b910beeea9c6c2ed6c7b1bd26724bd813.tar.gz cpython-38387b8b910beeea9c6c2ed6c7b1bd26724bd813.tar.bz2 |
bug [ 728515 ] mmap's resize method resizes the file in win32 but not unix
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/mmapmodule.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index aaa4925..f58e0f1 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -421,6 +421,11 @@ mmap_resize_method(mmap_object *self, return NULL; #else } else { + if (ftruncate(self->fd, new_size) == -1) { + PyErr_SetFromErrno(mmap_module_error); + return NULL; + } + void *newmap; #ifdef MREMAP_MAYMOVE @@ -910,7 +915,12 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) if (m_obj == NULL) {return NULL;} m_obj->size = (size_t) map_size; m_obj->pos = (size_t) 0; - m_obj->fd = fd; + m_obj->fd = dup(fd); + if (m_obj->fd == -1) { + Py_DECREF(m_obj); + PyErr_SetFromErrno(mmap_module_error); + return NULL; + } m_obj->data = mmap(NULL, map_size, prot, flags, fd, 0); |