Index: lib/Support/Windows/Memory.inc =================================================================== --- lib/Support/Windows/Memory.inc +++ lib/Support/Windows/Memory.inc @@ -135,8 +135,9 @@ DWORD Protect = getWindowsProtectionFlags(Flags); + size_t AllocSize = NumBlocks * Granularity; void *PA = ::VirtualAlloc(reinterpret_cast(Start), - NumBlocks * Granularity, AllocType, Protect); + AllocSize, AllocType, Protect); if (PA == NULL) { if (NearBlock || HugePages) { // Try again without the NearBlock hint and without large memory pages @@ -148,11 +149,11 @@ MemoryBlock Result; Result.Address = PA; - Result.Size = NumBlocks*Granularity; + Result.Size = NumBytes; Result.Flags = (Flags & ~MF_HUGE_HINT) | (HugePages ? MF_HUGE_HINT : 0); if (Flags & MF_EXEC) - Memory::InvalidateInstructionCache(Result.Address, Result.Size); + Memory::InvalidateInstructionCache(Result.Address, AllocSize); return Result; }