mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
bug 723472 - don't trigger an OOM abort on a zero-size allocation. r=cjones
This commit is contained in:
parent
0c3a78bf21
commit
0226614b64
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user