diff --git a/courgette/memory_allocator.h b/courgette/memory_allocator.h index d356a3b598d096..e332a32cee1708 100644 --- a/courgette/memory_allocator.h +++ b/courgette/memory_allocator.h @@ -236,6 +236,10 @@ class MemoryAllocator { } } } + // If the above fails (e.g. because we are in a sandbox), just try the heap. + if (!mem && base::UncheckedMalloc(bytes, reinterpret_cast(&mem))) { + mem[0] = static_cast(HEAP_ALLOCATION); + } return mem ? reinterpret_cast(mem + sizeof(T)) : NULL; }