Always delete the old content array so that we run destructors. b=397022 r+sr=bzbarsky a=roc
git-svn-id: svn://10.0.0.236/trunk@236756 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
94f24de901
commit
5ea7455586
@ -1402,17 +1402,20 @@ nsChangeHint nsStyleContent::MaxDifference()
|
||||
|
||||
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
|
||||
{
|
||||
if (aCount != mContentCount) {
|
||||
DELETE_ARRAY_IF(mContents);
|
||||
if (aCount) {
|
||||
mContents = new nsStyleContentData[aCount];
|
||||
if (! mContents) {
|
||||
mContentCount = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// We need to run the destructors of the elements of mContents, so we
|
||||
// delete and reallocate even if aCount == mContentCount. (If
|
||||
// nsStyleContentData had its members private and managed their
|
||||
// ownership on setting, we wouldn't need this, but that seems
|
||||
// unnecessary at this point.)
|
||||
DELETE_ARRAY_IF(mContents);
|
||||
if (aCount) {
|
||||
mContents = new nsStyleContentData[aCount];
|
||||
if (! mContents) {
|
||||
mContentCount = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mContentCount = aCount;
|
||||
}
|
||||
mContentCount = aCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user