# HG changeset patch # User Kartikaya Gupta # Date 1521554487 14400 # Node ID c5277595787694fdbfaab5ccf36da79418f18997 # Parent f4669f081b150c798622fc4b3afa0f653e166783 Bug 1447157 - Avoid crashing if an unregistered layer tree gets adopted. r=botond It looks like we can get layer tree adopted messages when the compositor doesn't have an entry for that layer tree in sIndirectLayerTrees. So we need to null-check all the things we pull out of that structure - all the properties are already null-checked except for the mParent. This patch adds a null check around that as well. MozReview-Commit-ID: 2fb4SdvgSrG diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1589,20 +1589,22 @@ CompositorBridgeParent::RecvMapAndNotify mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild(const uint64_t& child) { RefPtr oldApzSampler; APZCTreeManagerParent* parent; { MonitorAutoLock lock(*sIndirectLayerTreesLock); - // We currently don't support adopting children from one compositor to - // another if the two compositors don't have the same options. - MOZ_ASSERT(sIndirectLayerTrees[child].mParent->mOptions == mOptions); - oldApzSampler = sIndirectLayerTrees[child].mParent->mApzSampler; + if (sIndirectLayerTrees[child].mParent) { + // We currently don't support adopting children from one compositor to + // another if the two compositors don't have the same options. + MOZ_ASSERT(sIndirectLayerTrees[child].mParent->mOptions == mOptions); + oldApzSampler = sIndirectLayerTrees[child].mParent->mApzSampler; + } NotifyChildCreated(child); if (sIndirectLayerTrees[child].mLayerTree) { sIndirectLayerTrees[child].mLayerTree->SetLayerManager(mLayerManager, GetAnimationStorage()); // Trigger composition to handle a case that mLayerTree was not composited yet // by previous CompositorBridgeParent, since nsRefreshDriver might wait composition complete. ScheduleComposition(); } if (mWrBridge && sIndirectLayerTrees[child].mWrBridge) {