From 77dc77607d70acba487da70dfaa3f52a6e41a7ab Mon Sep 17 00:00:00 2001 From: "mbelshe@google.com" Date: Mon, 19 Oct 2009 18:30:01 +0000 Subject: Modify allocator to use malloc for the realloc(0, size) case. This works around webkit sensitivity to allocators that return zero in this case. BUG=20200 TEST=none Review URL: http://codereview.chromium.org/302005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29425 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/tcmalloc/allocator_shim.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'third_party') 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 -- cgit v1.1