Bug 442012 - Allocating more than 2GB of memory in mozilla is never a good idea. On 64-bit systems PRSize and size_t are 64-bit and so truncation from PRSize to PRUint32 could cause weird behavior errors. Prevent these huge allocations. r=wtc sr=dveditz

This commit is contained in:
Benjamin Smedberg 2008-11-26 14:38:53 -05:00
parent 92e9d4714f
commit 0c8ea59022

View File

@ -293,6 +293,9 @@ nsMemoryImpl::sFlushEvent;
XPCOM_API(void*)
NS_Alloc(PRSize size)
{
if (size > PR_INT32_MAX)
return nsnull;
void* result = MALLOC1(size);
if (! result) {
// Request an asynchronous flush
@ -304,6 +307,9 @@ NS_Alloc(PRSize size)
XPCOM_API(void*)
NS_Realloc(void* ptr, PRSize size)
{
if (size > PR_INT32_MAX)
return nsnull;
void* result = REALLOC1(ptr, size);
if (! result && size != 0) {
// Request an asynchronous flush