Mercurial > cpython-lru_cache-weakref
diff Modules/mmapmodule.c @ 35408:3bb932801b64 legacy-trunk
bug [ 728515 ] mmap's resize method resizes the file in win32 but not unix
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Wed, 24 Aug 2005 07:17:40 +0000 |
| parents | b40586129bb0 |
| children | 35a99eccaca6 |
line wrap: on
line diff
--- a/Modules/mmapmodule.c Wed Aug 24 07:06:25 2005 +0000 +++ b/Modules/mmapmodule.c Wed Aug 24 07:17:40 2005 +0000 @@ -421,6 +421,11 @@ 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 @@ 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);
