Index: src/spaces.cc |
diff --git a/src/spaces.cc b/src/spaces.cc |
index 6144464304898fdb3fe814cceeadc87f5e48881d..a5d61ebb59c6f09ae7f4f523c7d801224f7ed7fd 100644 |
--- a/src/spaces.cc |
+++ b/src/spaces.cc |
@@ -362,15 +362,22 @@ Address MemoryAllocator::AllocateAlignedMemory(size_t size, |
if (base == NULL) return NULL; |
if (executable == EXECUTABLE) { |
- CommitCodePage(&reservation, base, size); |
+ if (!CommitCodePage(&reservation, base, size)) { |
+ base = NULL; |
+ } |
} else { |
- if (!reservation.Commit(base, |
- size, |
- executable == EXECUTABLE)) { |
- return NULL; |
+ if (!reservation.Commit(base, size, false)) { |
+ base = NULL; |
} |
} |
+ if (base == NULL) { |
+ // Failed to commit the body. Release the mapping and any partially |
+ // commited regions inside it. |
+ reservation.Release(); |
+ return NULL; |
+ } |
+ |
controller->TakeControl(&reservation); |
return base; |
} |