Index: src/spaces.cc |
=================================================================== |
--- src/spaces.cc (revision 11472) |
+++ src/spaces.cc (working copy) |
@@ -362,15 +362,22 @@ |
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; |
} |