Bug 1581475 - Add missing null-check in CreateBrudhForPattern. r=jrmuizel

The crash reports all have allocation failures in their gfx critical log indicating that the best we can do is bail out without crashing and hope that enough memory will be freed before we run into an infallible allocation.

Differential Revision: https://phabricator.services.mozilla.com/D63085

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Silva 2020-02-18 13:52:42 +00:00
parent 3f9b0177d2
commit 1ff2e87bb4

View File

@ -2044,6 +2044,10 @@ already_AddRefed<ID2D1Brush> DrawTargetD2D1::CreateBrushForPattern(
surf, mat, pat->mExtendMode,
!pat->mSamplingRect.IsEmpty() ? &pat->mSamplingRect : nullptr);
if (!image) {
return CreateTransparentBlackBrush();
}
if (surf->GetFormat() == SurfaceFormat::A8) {
// See bug 1251431, at least FillOpacityMask does not appear to allow a
// source bitmapbrush with source format A8. This creates a BGRA surface
@ -2061,6 +2065,11 @@ already_AddRefed<ID2D1Brush> DrawTargetD2D1::CreateBrushForPattern(
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED)),
getter_AddRefs(tmpBitmap));
if (!tmpBitmap) {
return CreateTransparentBlackBrush();
}
mDC->GetTarget(getter_AddRefs(oldTarget));
mDC->SetTarget(tmpBitmap);
@ -2073,10 +2082,6 @@ already_AddRefed<ID2D1Brush> DrawTargetD2D1::CreateBrushForPattern(
}
}
if (!image) {
return CreateTransparentBlackBrush();
}
if (pat->mSamplingRect.IsEmpty()) {
RefPtr<ID2D1Bitmap> bitmap;
HRESULT hr = image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap));