| Index: base/process/memory_linux.cc
|
| diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc
|
| index f81429b2ac0d7ed72eeeb3d2c4d7882ff6428744..01b7614e79b2e2ede4f6de57758586ee462dd0e7 100644
|
| --- a/base/process/memory_linux.cc
|
| +++ b/base/process/memory_linux.cc
|
| @@ -115,6 +115,10 @@ int posix_memalign(void** ptr, size_t alignment, size_t size) {
|
|
|
| } // extern C
|
|
|
| +void* UncheckedMalloc(size_t size) {
|
| + return __libc_malloc(size);
|
| +}
|
| +
|
| #else
|
|
|
| // TODO(mostynb@opera.com): dlsym dance
|
| @@ -123,6 +127,29 @@ int posix_memalign(void** ptr, size_t alignment, size_t size) {
|
|
|
| #endif // !*_SANITIZER
|
|
|
| +#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
|
| + defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
|
| + (!defined(LIBC_GLIBC) && !defined(USE_TCMALLOC))
|
| +
|
| +void* UncheckedMalloc(size_t size) {
|
| + return malloc(size);
|
| +}
|
| +
|
| +#endif
|
| +
|
| +void* UncheckedCalloc(size_t num_items, size_t size) {
|
| + const size_t alloc_size = num_items * size;
|
| +
|
| + // Overflow check
|
| + if (alloc_size && (alloc_size / size) != num_items)
|
| + return NULL;
|
| +
|
| + void* result = UncheckedMalloc(alloc_size);
|
| + if (result)
|
| + memset(result, 0, alloc_size);
|
| + return result;
|
| +}
|
| +
|
| void EnableTerminationOnHeapCorruption() {
|
| // On Linux, there nothing to do AFAIK.
|
| }
|
|
|