Issue #1860 - Follow-up: Make sure we don't add duplicate frames

Changing to vector makes manipulating display list items more risky.
This is to make sure we don't inadvertently end up with duplicates in
the list of display items avoiding double-free scenarios.
This commit is contained in:
Moonchild 2022-04-18 14:31:55 +02:00 committed by roytam1
commit f039cc7ef8

View file

@ -162,7 +162,12 @@ void
FrameLayerBuilder::DisplayItemData::AddFrame(nsIFrame* aFrame)
{
MOZ_RELEASE_ASSERT(mLayer);
mFrameList.AppendElement(aFrame);
// Make sure we don't add duplicate frames as we're storing these as vectors.
// See UXP Issue #1860
if (!mFrameList.Contains(aFrame)) {
mFrameList.AppendElement(aFrame);
}
nsTArray<DisplayItemData*>* array =
aFrame->GetProperty(FrameLayerBuilder::LayerManagerDataProperty());