Chromium Code Reviews| Index: sandbox/win/src/sandbox_nt_util.cc |
| diff --git a/sandbox/win/src/sandbox_nt_util.cc b/sandbox/win/src/sandbox_nt_util.cc |
| index ed1d908ad6907d7397026dbc91f6d2403f0132c7..1c3a1c250d13f32c7896dc253c4c9c471f772de2 100644 |
| --- a/sandbox/win/src/sandbox_nt_util.cc |
| +++ b/sandbox/win/src/sandbox_nt_util.cc |
| @@ -547,17 +547,21 @@ void* operator new(size_t size, sandbox::AllocationType type, |
| void* near_to) { |
| using namespace sandbox; |
| - if (NT_ALLOC == type) { |
| - if (!InitHeap()) |
| - return NULL; |
| - |
| + void* result = NULL; |
| + if (NT_ALLOC == type && InitHeap()) { |
| // Use default flags for the allocation. |
| - return g_nt.RtlAllocateHeap(sandbox::g_heap, 0, size); |
| + 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(); |
|
rvargas (doing something else)
2014/09/10 22:22:58
This is a change in behavior for debug builds :(
Nico
2014/09/10 22:24:27
Oh, you mean when type == NOT_ALLOC but InitHead()
|
| } |
| - 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) { |