[Python-checkins] r69944 - sandbox/trunk/mmap/Modules/mmapmodule.c
hirokazu.yamamoto
python-checkins at python.org
Tue Feb 24 21:27:43 CET 2009
Author: hirokazu.yamamoto
Date: Tue Feb 24 21:27:43 2009
New Revision: 69944
Log:
Issue #2733: Fixed resize error for anonymous mapping object (windows).
I'm doubtful anonymous mapping object is resizable, but if another process
changes file size between SetFilePointer and CreateFileMapping it may cause
segfault, so I think explicitly specifying size is good practice.
Modified:
sandbox/trunk/mmap/Modules/mmapmodule.c
Modified: sandbox/trunk/mmap/Modules/mmapmodule.c
==============================================================================
--- sandbox/trunk/mmap/Modules/mmapmodule.c (original)
+++ sandbox/trunk/mmap/Modules/mmapmodule.c Tue Feb 24 21:27:43 2009
@@ -451,17 +451,21 @@
off_hi = 0;
off_lo = (DWORD)self->offset;
#endif
- SetFilePointer(self->file_handle,
- newSizeLow, &newSizeHigh, FILE_BEGIN);
- /* Change the size of the file */
- SetEndOfFile(self->file_handle);
+ /* XXX: Is anonymous map really resizable? */
+ if (self->file_handle != INVALID_HANDLE_VALUE) {
+ DWORD copySizeHigh = newSizeHigh;
+ SetFilePointer(self->file_handle,
+ newSizeLow, ©SizeHigh, FILE_BEGIN);
+ /* Change the size of the file */
+ SetEndOfFile(self->file_handle);
+ }
/* Create another mapping object and remap the file view */
map_handle = CreateFileMapping(
self->file_handle,
NULL,
PAGE_READWRITE,
- 0,
- 0,
+ newSizeHigh,
+ newSizeLow,
self->tagname);
if (map_handle != NULL) {
self->data = (char *) MapViewOfFile(map_handle,
More information about the Python-checkins
mailing list