Bug 1451376 - Properly enforce single PrintingParent per content process. r=jld, a=RyanVM
authorBob Owen <bobowencode@gmail.com>
Tue, 10 Apr 2018 15:36:26 +0100
changeset 357021 af885a1bd293e5cd71105c770012f3aecc832747
parent 357020 c61127b443f2f893ecd293eba221a324a08c49bb
child 357022 666fc84ec72d4e1a9f71ca6a4fdccfa960a1e795
push id7629
push userryanvm@gmail.com
push dateTue, 10 Apr 2018 18:29:02 +0000
treeherdermozilla-esr52@666fc84ec72d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld, RyanVM
bugs1451376
milestone52.7.4
Bug 1451376 - Properly enforce single PrintingParent per content process. r=jld, a=RyanVM
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3287,34 +3287,41 @@ ContentParent::DeallocPNeckoParent(PNeck
   delete necko;
   return true;
 }
 
 PPrintingParent*
 ContentParent::AllocPPrintingParent()
 {
 #ifdef NS_PRINTING
-  MOZ_ASSERT(!mPrintingParent,
-             "Only one PrintingParent should be created per process.");
+  MOZ_RELEASE_ASSERT(!mPrintingParent,
+                     "Only one PrintingParent should be created per process.");
 
   // Create the printing singleton for this process.
   mPrintingParent = new PrintingParent();
+
+  // Take another reference for IPDL code.
+  mPrintingParent.get()->AddRef();
+
   return mPrintingParent.get();
 #else
   MOZ_ASSERT_UNREACHABLE("Should never be created if no printing.");
   return nullptr;
 #endif
 }
 
 bool
 ContentParent::DeallocPPrintingParent(PPrintingParent* printing)
 {
 #ifdef NS_PRINTING
-  MOZ_ASSERT(mPrintingParent == printing,
-             "Only one PrintingParent should have been created per process.");
+  MOZ_RELEASE_ASSERT(mPrintingParent == printing,
+    "Only one PrintingParent should have been created per process.");
+
+  // Release reference taken for IPDL code.
+  static_cast<PrintingParent*>(printing)->Release();
 
   mPrintingParent = nullptr;
 #else
   MOZ_ASSERT_UNREACHABLE("Should never have been created if no printing.");
 #endif
   return true;
 }