Commit 71a19439 authored by erikcorry's avatar erikcorry Committed by Commit bot

If a code space commit partially succeeds, free the memory

R=hpayer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1086253004

Cr-Commit-Position: refs/heads/master@{#27884}
parent 9716468a
...@@ -875,30 +875,28 @@ bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm, ...@@ -875,30 +875,28 @@ bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm,
Address start, size_t commit_size, Address start, size_t commit_size,
size_t reserved_size) { size_t reserved_size) {
// Commit page header (not executable). // Commit page header (not executable).
if (!vm->Commit(start, CodePageGuardStartOffset(), false)) { Address header = start;
return false; size_t header_size = CodePageGuardStartOffset();
} if (vm->Commit(header, header_size, false)) {
// Create guard page after the header.
// Create guard page after the header. if (vm->Guard(start + CodePageGuardStartOffset())) {
if (!vm->Guard(start + CodePageGuardStartOffset())) { // Commit page body (executable).
return false; Address body = start + CodePageAreaStartOffset();
} size_t body_size = commit_size - CodePageGuardStartOffset();
if (vm->Commit(body, body_size, true)) {
// Commit page body (executable). // Create guard page before the end.
if (!vm->Commit(start + CodePageAreaStartOffset(), if (vm->Guard(start + reserved_size - CodePageGuardSize())) {
commit_size - CodePageGuardStartOffset(), true)) { UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() +
return false; commit_size -
} CodePageGuardStartOffset());
return true;
// Create guard page before the end. }
if (!vm->Guard(start + reserved_size - CodePageGuardSize())) { vm->Uncommit(body, body_size);
return false; }
}
vm->Uncommit(header, header_size);
} }
return false;
UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() +
commit_size -
CodePageGuardStartOffset());
return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment