Index: courgette/memory_allocator.h |
diff --git a/courgette/memory_allocator.h b/courgette/memory_allocator.h |
index 3f5143252102f973d0e61cfc4f6b1d1e37b8bb6f..dc1131da6975719e851b3b01682e470322f32c67 100644 |
--- a/courgette/memory_allocator.h |
+++ b/courgette/memory_allocator.h |
@@ -237,6 +237,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<void**>(&mem))) { |
+ mem[0] = static_cast<uint8_t>(HEAP_ALLOCATION); |
+ } |
return mem ? reinterpret_cast<pointer>(mem + sizeof(T)) : NULL; |
} |