Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: courgette/memory_allocator.h

Issue 2775893002: Fall back to heap allocation in courgette alloc. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698