diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 18:30:01 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 18:30:01 +0000 |
commit | 77dc77607d70acba487da70dfaa3f52a6e41a7ab (patch) | |
tree | 798074dd34b88e29fec64c5132339bcab2c63fca /third_party | |
parent | ed1dcd7826316e56bc14faee7c39121bcc9981a5 (diff) | |
download | chromium_src-77dc77607d70acba487da70dfaa3f52a6e41a7ab.zip chromium_src-77dc77607d70acba487da70dfaa3f52a6e41a7ab.tar.gz chromium_src-77dc77607d70acba487da70dfaa3f52a6e41a7ab.tar.bz2 |
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
Diffstat (limited to 'third_party')
-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 |