mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 554255 (Limit resource use to something sane). r=sicking, sr=jst.
This commit is contained in:
parent
0578abb1ad
commit
2bcc2547ea
@ -178,7 +178,15 @@ txNodeSorter::sortNodeSet(txNodeSet* aNodes, txExecutionState* aEs,
|
||||
|
||||
// Create and set up memoryblock for sort-values and indexarray
|
||||
PRUint32 len = static_cast<PRUint32>(aNodes->size());
|
||||
void* mem = PR_Malloc(len * (sizeof(PRUint32) + mNKeys * sizeof(TxObject*)));
|
||||
|
||||
// Limit resource use to something sane.
|
||||
PRUint32 itemSize = sizeof(PRUint32) + mNKeys * sizeof(TxObject*);
|
||||
if (mNKeys > (PR_UINT32_MAX - sizeof(PRUint32)) / sizeof(TxObject*) ||
|
||||
len >= PR_UINT32_MAX / itemSize) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
void* mem = PR_Malloc(len * itemSize);
|
||||
NS_ENSURE_TRUE(mem, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRUint32* indexes = static_cast<PRUint32*>(mem);
|
||||
|
Loading…
Reference in New Issue
Block a user