Commit 31cc2fdd authored by mbelshe@google.com's avatar mbelshe@google.com

Fix realloc to not call the new_handler (which is for failures)

when the request was for realloc(ptr, 0).  Calling realloc(ptr, 0)
is valid, and we should delete ptr and return NULL.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/194040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25700 0039d316-1c4b-4281-b951-d872f2087c98
parent 84934a22
......@@ -160,7 +160,11 @@ void* realloc(void* ptr, size_t size) __THROW {
// TCMalloc case.
new_ptr = do_realloc(ptr, size);
#endif
if (new_ptr)
// Subtle warning: NULL return does not alwas indicate out-of-memory. If
// the requested new size is zero, realloc should free the ptr and return
// NULL.
if (new_ptr || !size)
return new_ptr;
if (!new_mode || !call_new_handler(true))
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment