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+a=dveditz for 1.9.0

git-svn-id: svn://10.0.0.236/trunk@255713 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
benjamin%smedbergs.us 2009-01-05 21:08:08 +00:00
parent 8575d7b1f7
commit fb151b04b6

View File

@ -278,6 +278,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
@ -289,6 +292,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