Bug 588643 - Crash in [@ nsDocShell::SetHistoryEntry ], r=bent/neil, a=blocking

This commit is contained in:
Olli Pettay 2010-08-21 00:26:52 +03:00
parent f8ab79e415
commit 7f42094ff8

View File

@ -642,7 +642,17 @@ nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset)
}
#endif
mChildren.InsertObjectAt(aChild, aOffset);
// InsertObjectAt allows only appending one object.
// If aOffset is larger than Count(), we must first manually
// set the capacity.
if (aOffset > mChildren.Count()) {
mChildren.SetCount(aOffset);
}
if (!mChildren.InsertObjectAt(aChild, aOffset)) {
NS_WARNING("Adding a child failed!");
aChild->SetParent(nsnull);
return NS_ERROR_FAILURE;
}
return NS_OK;
}