From f243b7b4af1242c2b80726e462bac045d70c37f0 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Tue, 10 Apr 2018 15:36:26 +0100 Subject: Bug 1451376 - Properly enforce single PrintingParent per content process. r=jld, a=RyanVM --HG-- extra : source : 6e0fe40d8a55a986a26844393853722824918ffe extra : intermediate-source : 8364f4c4f877f5edfb03ddf1304840b9f2cf7b11 --- dom/ipc/ContentParent.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'dom/ipc') diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 73621df22..286f1d851 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -3224,11 +3224,15 @@ 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."); @@ -3240,8 +3244,11 @@ 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(printing)->Release(); mPrintingParent = nullptr; #else -- cgit v1.2.3