Bug 1749283 - Add a null check for mPrintTarget in nsDeviceContext::CreateRenderingContextCommon. r=dholbert

mPrintTarget can be nulled out and the caller needs to deal with null
returns already, so this should address the crash.

Differential Revision: https://phabricator.services.mozilla.com/D137473
This commit is contained in:
Emilio Cobos Álvarez
2022-02-01 18:44:13 +00:00
parent a3e3beb4b7
commit e95f38a6de

View File

@@ -171,6 +171,11 @@ already_AddRefed<gfxContext> nsDeviceContext::CreateRenderingContextCommon(
MOZ_ASSERT(IsPrinterContext());
MOZ_ASSERT(mWidth > 0 && mHeight > 0);
if (NS_WARN_IF(!mPrintTarget)) {
// Printing canceled already.
return nullptr;
}
RefPtr<gfx::DrawTarget> dt;
if (aWantReferenceContext) {
dt = mPrintTarget->GetReferenceDrawTarget();