mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
[memory] Guard OOM reporter from incorrectly reported (too small) size.
This commit is contained in:
parent
0548a39ff3
commit
1f7d8d3a36
1 changed files with 3 additions and 1 deletions
|
|
@ -64,6 +64,7 @@ extern "C" MOZ_MEMORY_API char *strndup_impl(const char *, size_t);
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/mozalloc_oom.h" // for mozalloc_handle_oom
|
||||
|
|
@ -84,7 +85,8 @@ moz_xcalloc(size_t nmemb, size_t size)
|
|||
{
|
||||
void* ptr = calloc_impl(nmemb, size);
|
||||
if (MOZ_UNLIKELY(!ptr && nmemb && size)) {
|
||||
mozalloc_handle_oom(size);
|
||||
mozilla::CheckedInt<size_t> totalSize = mozilla::CheckedInt<size_t>(nmemb) * size;
|
||||
mozalloc_handle_oom(totalSize.isValid() ? totalSize.value() : SIZE_MAX);
|
||||
return moz_xcalloc(nmemb, size);
|
||||
}
|
||||
return ptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue