Bug 1451376: Properly enforce single PrintingParent per content process. r=jld
authorBob Owen <bobowencode@gmail.com>
Tue, 10 Apr 2018 15:36:26 +0100
changeset 412593 6e0fe40d8a55a986a26844393853722824918ffe
parent 412592 3d3b88d74ad49ffe1365cf02ff96303d3fc969e8
child 412594 0a2dae2d8cf9f628c55668514c54a23da446d5de
child 412630 efa95de482d7315e5eb660b2d16bfc44bd6b768d
push id33809
push userrgurzau@mozilla.com
push dateTue, 10 Apr 2018 16:54:59 +0000
treeherdermozilla-central@0a2dae2d8cf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1451376
milestone61.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 1451376: Properly enforce single PrintingParent per content process. r=jld
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3403,34 +3403,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;
 }