Always delete the old content array so that we run destructors. b=397022 r+sr=bzbarsky a=roc

This commit is contained in:
dbaron@dbaron.org 2007-09-27 09:27:48 -07:00
Родитель 0926363321
Коммит c73c09fe83
1 изменённых файлов: 12 добавлений и 9 удалений

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

@ -1402,7 +1402,11 @@ nsChangeHint nsStyleContent::MaxDifference()
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
{
if (aCount != mContentCount) {
// 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];
@ -1412,7 +1416,6 @@ nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
}
}
mContentCount = aCount;
}
return NS_OK;
}