Bug 1451376 - Properly enforce single PrintingParent per content process. r=jld, a=RyanVM

--HG--
extra : source : 6e0fe40d8a55a986a26844393853722824918ffe
extra : intermediate-source : 8364f4c4f877f5edfb03ddf1304840b9f2cf7b11
This commit is contained in:
Bob Owen 2018-04-10 15:36:26 +01:00 • committed by Roy Tam
commit 6395d4600f

View file

@ -3224,11 +3224,15 @@ PPrintingParent*
ContentParent::AllocPPrintingParent() ContentParent::AllocPPrintingParent()
{ {
#ifdef NS_PRINTING #ifdef NS_PRINTING
MOZ_ASSERT(!mPrintingParent, MOZ_RELEASE_ASSERT(!mPrintingParent,
"Only one PrintingParent should be created per process."); "Only one PrintingParent should be created per process.");
// Create the printing singleton for this process. // Create the printing singleton for this process.
mPrintingParent = new PrintingParent(); mPrintingParent = new PrintingParent();
// Take another reference for IPDL code.
mPrintingParent.get()->AddRef();
return mPrintingParent.get(); return mPrintingParent.get();
#else #else
MOZ_ASSERT_UNREACHABLE("Should never be created if no printing."); MOZ_ASSERT_UNREACHABLE("Should never be created if no printing.");
@ -3240,8 +3244,11 @@ bool
ContentParent::DeallocPPrintingParent(PPrintingParent* printing) ContentParent::DeallocPPrintingParent(PPrintingParent* printing)
{ {
#ifdef NS_PRINTING #ifdef NS_PRINTING
MOZ_ASSERT(mPrintingParent == printing, MOZ_RELEASE_ASSERT(mPrintingParent == printing,
"Only one PrintingParent should have been created per process."); "Only one PrintingParent should have been created per process.");
// Release reference taken for IPDL code.
static_cast<PrintingParent*>(printing)->Release();
mPrintingParent = nullptr; mPrintingParent = nullptr;
#else #else