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 460690 8364f4c4f877f5edfb03ddf1304840b9f2cf7b11
parent 460689 65d2876668ea6a58f1399b01805fa16700e37b6c
child 460691 29b2342e2a32c31d8b9615a8ca2968e8da6f6f93
push id9018
push userryanvm@gmail.com
push dateTue, 10 Apr 2018 18:20:19 +0000
treeherdermozilla-beta@29b2342e2a32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld, RyanVM
bugs1451376
milestone60.0
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
@@ -3342,34 +3342,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;
 }