summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sandbox/win/src/sandbox_nt_util.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/sandbox/win/src/sandbox_nt_util.cc b/sandbox/win/src/sandbox_nt_util.cc
index ed1d908..28ddd47 100644
--- a/sandbox/win/src/sandbox_nt_util.cc
+++ b/sandbox/win/src/sandbox_nt_util.cc
@@ -547,17 +547,23 @@ void* operator new(size_t size, sandbox::AllocationType type,
void* near_to) {
using namespace sandbox;
+ void* result = NULL;
if (NT_ALLOC == type) {
- if (!InitHeap())
- return NULL;
-
- // Use default flags for the allocation.
- return g_nt.RtlAllocateHeap(sandbox::g_heap, 0, size);
+ if (InitHeap()) {
+ // Use default flags for the allocation.
+ result = g_nt.RtlAllocateHeap(sandbox::g_heap, 0, size);
+ }
} else if (NT_PAGE == type) {
- return AllocateNearTo(near_to, size);
+ result = AllocateNearTo(near_to, size);
+ } else {
+ NOTREACHED_NT();
}
- NOTREACHED_NT();
- return NULL;
+
+ // TODO: Returning NULL from operator new has undefined behavior, but
+ // the Allocate() functions called above can return NULL. Consider checking
+ // for NULL here and crashing or throwing.
+
+ return result;
}
void operator delete(void* memory, sandbox::AllocationType type) {