diff options
-rw-r--r-- | third_party/tcmalloc/allocator_shim.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/third_party/tcmalloc/allocator_shim.cc b/third_party/tcmalloc/allocator_shim.cc index 2ef4a7a..39161d4 100644 --- a/third_party/tcmalloc/allocator_shim.cc +++ b/third_party/tcmalloc/allocator_shim.cc @@ -140,6 +140,12 @@ void free(void* p) __THROW { } void* realloc(void* ptr, size_t size) __THROW { + // Webkit is brittle for allocators that return NULL for malloc(0). The + // realloc(0, 0) code path does not guarantee a non-NULL return, so be sure + // to call malloc for this case. + if (!ptr) + return malloc(size); + void* new_ptr; for (;;) { #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING |