Bug 1561058 - Null check ContentParent within ContentParent::RecvPostMessage, r=peterv
authorNika Layzell <nika@thelayzells.com>
Thu, 27 Jun 2019 15:03:24 +0000
changeset 543240 72051a14f93ee1b0fc57fee1eff0ebd7178a6127
parent 543239 65f27711841298fd73e555bf3b6d316a079dfbbe
child 543241 c04923179a923f5a94af9b6df475c266adbf39f0
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1561058
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1561058 - Null check ContentParent within ContentParent::RecvPostMessage, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D35878
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5940,26 +5940,32 @@ mozilla::ipc::IPCResult ContentParent::R
     const PostMessageData& aData) {
   if (!aContext) {
     MOZ_LOG(
         BrowsingContext::GetLog(), LogLevel::Debug,
         ("ParentIPC: Trying to send a message to dead or detached context"));
     return IPC_OK();
   }
 
-  ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
-  ContentParent* cp = cpm->GetContentProcessById(
-      ContentParentId(aContext->Canonical()->OwnerProcessId()));
+  RefPtr<ContentParent> cp = aContext->Canonical()->GetContentParent();
+  if (!cp) {
+    MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
+            ("ParentIPC: Trying to send PostMessage to dead content process"));
+    return IPC_OK();
+  }
+
   StructuredCloneData messageFromChild;
   UnpackClonedMessageDataForParent(aMessage, messageFromChild);
+
   ClonedMessageData message;
   if (!BuildClonedMessageDataForParent(cp, messageFromChild, message)) {
     // FIXME Logging?
     return IPC_OK();
   }
+
   Unused << cp->SendWindowPostMessage(aContext, message, aData);
   return IPC_OK();
 }
 
 void ContentParent::OnBrowsingContextGroupSubscribe(
     BrowsingContextGroup* aGroup) {
   MOZ_DIAGNOSTIC_ASSERT(aGroup);
   mGroups.PutEntry(aGroup);