Chromium Code Reviews| Index: src/platform-win32.cc |
| =================================================================== |
| --- src/platform-win32.cc (revision 8619) |
| +++ src/platform-win32.cc (working copy) |
| @@ -913,11 +913,14 @@ |
| } |
| LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address), |
| - msize, |
| + msize + Page::kPageSize, |
|
Vyacheslav Egorov (Chromium)
2011/07/12 23:23:29
This looks slightly suspicious to me.
MemoryAlloc
Cris Neckar
2011/07/14 17:32:28
Done.
|
| MEM_COMMIT | MEM_RESERVE, |
| prot); |
| if (mbase == NULL && address != 0) |
| - mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot); |
| + mbase = VirtualAlloc(NULL, |
| + msize + Page::kPageSize, |
| + MEM_COMMIT | MEM_RESERVE, |
| + prot); |
| if (mbase == NULL) { |
| LOG(ISOLATE, StringEvent("OS::Allocate", "VirtualAlloc failed")); |
| @@ -925,8 +928,12 @@ |
| } |
| ASSERT(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment())); |
| + *allocated = msize; |
| - *allocated = msize; |
| + DWORD old_protect; |
| + VirtualProtect(mbase, Page::kPageSize, PAGE_READONLY | PAGE_GUARD, &old_protect); |
| + mbase = static_cast<BYTE*>(mbase) + Page::kPageSize; |
| + |
| UpdateAllocatedSpaceLimits(mbase, static_cast<int>(msize)); |
| return mbase; |
| } |
| @@ -934,7 +941,7 @@ |
| void OS::Free(void* address, const size_t size) { |
| // TODO(1240712): VirtualFree has a return value which is ignored here. |
| - VirtualFree(address, 0, MEM_RELEASE); |
| + VirtualFree(static_cast<BYTE*>(address) - Page::kPageSize, 0, MEM_RELEASE); |
| USE(size); |
| } |