bug 9848 - check for out of memory when calling new. r=dcone.

This commit is contained in:
karnaze%netscape.com 2000-11-30 15:53:55 +00:00
Родитель fab4ad2b34
Коммит 110acb9a75
12 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -1914,6 +1914,7 @@ PRBool BasicTableLayoutStrategy::ColIsSpecifiedAsMinimumWidth(PRInt32 aColIndex)
void BasicTableLayoutStrategy::Dump(PRInt32 aIndent)
{
char* indent = new char[aIndent + 1];
if (!indent) return;
for (PRInt32 i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}

Просмотреть файл

@ -79,9 +79,14 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
nscoord totalColWidth = 0; // the sum of the widths of the columns
nscoord* colWidths = new PRBool[numCols];
if (!colWidths) return PR_FALSE;
nsCRT::memset(colWidths, WIDTH_NOT_SET, numCols*sizeof(nscoord));
nscoord* propInfo = new PRBool[numCols];
if (!propInfo) {
delete [] colWidths;
return PR_FALSE;
}
nsCRT::memset(propInfo, 0, numCols*sizeof(nscoord));
nscoord propTotal = 0;

Просмотреть файл

@ -711,6 +711,7 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
// Setup CellData for this cell
CellData* origData = new CellData(&aCellFrame);
if (!origData) return startColIndex;
SetMapCellAt(aMap, *origData, aRowIndex, startColIndex, PR_TRUE);
// initialize the cell frame
@ -757,6 +758,7 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
}
else {
cellData = new CellData(nsnull);
if (!cellData) return startColIndex;
if (rowX > aRowIndex) {
cellData->SetRowSpanOffset(rowX - aRowIndex);
}

Просмотреть файл

@ -1333,6 +1333,7 @@ GetCollapseOffsetProperty(nsIPresContext* aPresContext,
// The property isn't set yet, so allocate a new point, set the property,
// and return the newly allocated point
nsPoint* offset = new nsPoint(0, 0);
if (!offset) return nsnull;
frameManager->SetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
offset, DestroyPointFunc);

Просмотреть файл

@ -216,6 +216,7 @@ nscoord nsTableColFrame::GetPctWidth()
void nsTableColFrame::Dump(PRInt32 aIndent)
{
char* indent = new char[aIndent + 1];
if (!indent) return;
for (PRInt32 i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}

Просмотреть файл

@ -183,7 +183,9 @@ nsTableFrame::nsTableFrame()
#else
mColumnWidthsLength = 5;
mColumnWidths = new PRInt32[mColumnWidthsLength];
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
if (mColumnWidths) {
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
}
#endif
}
@ -217,6 +219,7 @@ nsTableFrame::Init(nsIPresContext* aPresContext,
// Create the cell map
// XXX Why do we do this for continuing frames?
mCellMap = new nsTableCellMap(aPresContext, *this);
if (!mCellMap) return NS_ERROR_OUT_OF_MEMORY;
// Let the base class do its processing
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
@ -3371,6 +3374,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
mColumnWidthsLength += kColumnWidthIncrement;
}
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
if (!newColumnWidthsArray) return;
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
if (mColumnWidths) {
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
@ -3393,6 +3397,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
mTableLayoutStrategy = new FixedTableLayoutStrategy(this);
else
mTableLayoutStrategy = new BasicTableLayoutStrategy(this, eCompatibility_NavQuirks == mode);
if (!mTableLayoutStrategy) return;
mTableLayoutStrategy->Initialize(aPresContext, aMaxElementSize, boxWidth, aReflowState);
mBits.mColumnWidthsValid=PR_TRUE;
}
@ -3761,6 +3766,7 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
if (!mColumnWidths) {
mColumnWidthsLength = mCellMap->GetColCount(); // mCellMap is valid since first inflow
mColumnWidths = new PRInt32[mColumnWidthsLength];
if (!mColumnWidths) return;
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
}

Просмотреть файл

@ -1914,6 +1914,7 @@ PRBool BasicTableLayoutStrategy::ColIsSpecifiedAsMinimumWidth(PRInt32 aColIndex)
void BasicTableLayoutStrategy::Dump(PRInt32 aIndent)
{
char* indent = new char[aIndent + 1];
if (!indent) return;
for (PRInt32 i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}

Просмотреть файл

@ -79,9 +79,14 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
nscoord totalColWidth = 0; // the sum of the widths of the columns
nscoord* colWidths = new PRBool[numCols];
if (!colWidths) return PR_FALSE;
nsCRT::memset(colWidths, WIDTH_NOT_SET, numCols*sizeof(nscoord));
nscoord* propInfo = new PRBool[numCols];
if (!propInfo) {
delete [] colWidths;
return PR_FALSE;
}
nsCRT::memset(propInfo, 0, numCols*sizeof(nscoord));
nscoord propTotal = 0;

Просмотреть файл

@ -711,6 +711,7 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
// Setup CellData for this cell
CellData* origData = new CellData(&aCellFrame);
if (!origData) return startColIndex;
SetMapCellAt(aMap, *origData, aRowIndex, startColIndex, PR_TRUE);
// initialize the cell frame
@ -757,6 +758,7 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
}
else {
cellData = new CellData(nsnull);
if (!cellData) return startColIndex;
if (rowX > aRowIndex) {
cellData->SetRowSpanOffset(rowX - aRowIndex);
}

Просмотреть файл

@ -1333,6 +1333,7 @@ GetCollapseOffsetProperty(nsIPresContext* aPresContext,
// The property isn't set yet, so allocate a new point, set the property,
// and return the newly allocated point
nsPoint* offset = new nsPoint(0, 0);
if (!offset) return nsnull;
frameManager->SetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
offset, DestroyPointFunc);

Просмотреть файл

@ -216,6 +216,7 @@ nscoord nsTableColFrame::GetPctWidth()
void nsTableColFrame::Dump(PRInt32 aIndent)
{
char* indent = new char[aIndent + 1];
if (!indent) return;
for (PRInt32 i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}

Просмотреть файл

@ -183,7 +183,9 @@ nsTableFrame::nsTableFrame()
#else
mColumnWidthsLength = 5;
mColumnWidths = new PRInt32[mColumnWidthsLength];
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
if (mColumnWidths) {
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
}
#endif
}
@ -217,6 +219,7 @@ nsTableFrame::Init(nsIPresContext* aPresContext,
// Create the cell map
// XXX Why do we do this for continuing frames?
mCellMap = new nsTableCellMap(aPresContext, *this);
if (!mCellMap) return NS_ERROR_OUT_OF_MEMORY;
// Let the base class do its processing
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
@ -3371,6 +3374,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
mColumnWidthsLength += kColumnWidthIncrement;
}
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
if (!newColumnWidthsArray) return;
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
if (mColumnWidths) {
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
@ -3393,6 +3397,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
mTableLayoutStrategy = new FixedTableLayoutStrategy(this);
else
mTableLayoutStrategy = new BasicTableLayoutStrategy(this, eCompatibility_NavQuirks == mode);
if (!mTableLayoutStrategy) return;
mTableLayoutStrategy->Initialize(aPresContext, aMaxElementSize, boxWidth, aReflowState);
mBits.mColumnWidthsValid=PR_TRUE;
}
@ -3761,6 +3766,7 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
if (!mColumnWidths) {
mColumnWidthsLength = mCellMap->GetColCount(); // mCellMap is valid since first inflow
mColumnWidths = new PRInt32[mColumnWidthsLength];
if (!mColumnWidths) return;
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
}