In CreateDIBSection, the offset into the file mapping does not have to
be a multiple of the memory allocation granularity.
diff --git a/objects/dib.c b/objects/dib.c
index 29f8090..5dfb6c9 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -930,7 +930,12 @@
if (dib->dsBm.bmBits)
{
if (dib->dshSection)
- UnmapViewOfFile(dib->dsBm.bmBits);
+ {
+ SYSTEM_INFO SystemInfo;
+ GetSystemInfo( &SystemInfo );
+ UnmapViewOfFile( (char *)dib->dsBm.bmBits -
+ (dib->dsOffset % SystemInfo.dwAllocationGranularity) );
+ }
else if (!dib->dsOffset)
VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
}