Skip to content

Commit

Permalink
bug 723472 - don't trigger an OOM abort on a zero-size allocation. r=…
Browse files Browse the repository at this point in the history
…cjones
  • Loading branch information
jfkthame committed Feb 2, 2012
1 parent 7fc6314 commit 7a7b2a5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions memory/mozalloc/mozalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void*
moz_xmalloc(size_t size)
{
void* ptr = malloc(size);
if (UNLIKELY(!ptr)) {
if (UNLIKELY(!ptr && size)) {
mozalloc_handle_oom(size);
return moz_xmalloc(size);
}
Expand All @@ -117,7 +117,7 @@ void*
moz_xcalloc(size_t nmemb, size_t size)
{
void* ptr = calloc(nmemb, size);
if (UNLIKELY(!ptr)) {
if (UNLIKELY(!ptr && nmemb && size)) {
mozalloc_handle_oom(size);
return moz_xcalloc(nmemb, size);
}
Expand All @@ -133,7 +133,7 @@ void*
moz_xrealloc(void* ptr, size_t size)
{
void* newptr = realloc(ptr, size);
if (UNLIKELY(!newptr)) {
if (UNLIKELY(!newptr && size)) {
mozalloc_handle_oom(size);
return moz_xrealloc(ptr, size);
}
Expand Down

0 comments on commit 7a7b2a5

Please sign in to comment.