Bug 1179049. Properly null check for draw target in box shadow code. r=mstange
authorMason Chang <mchang@mozilla.com>
Mon, 06 Jul 2015 08:58:22 -0700
changeset 275881 a61cdc2610c2e6eb7da3101bad7f3dbae8f62fcc
parent 275880 2a2556b4ed28af6da6180b33cbe2df438ad7f0cd
child 275882 cf4897732a5f9db1fb68596449be7416fa05a98c
push id3246
push usergijskruitbosch@gmail.com
push dateTue, 07 Jul 2015 09:06:38 +0000
reviewersmstange
bugs1179049
milestone42.0a1
Bug 1179049. Properly null check for draw target in box shadow code. r=mstange
gfx/thebes/gfxBlur.cpp
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -429,16 +429,21 @@ CreateBlurMask(const IntSize& aRectSize,
 
 static already_AddRefed<SourceSurface>
 CreateBoxShadow(DrawTarget& aDT, SourceSurface* aBlurMask, const gfxRGBA& aShadowColor)
 {
   IntSize blurredSize = aBlurMask->GetSize();
   gfxPlatform* platform = gfxPlatform::GetPlatform();
   RefPtr<DrawTarget> boxShadowDT =
     platform->CreateOffscreenContentDrawTarget(blurredSize, SurfaceFormat::B8G8R8A8);
+
+  if (!boxShadowDT) {
+    return nullptr;
+  }
+
   MOZ_ASSERT(boxShadowDT->GetType() == aDT.GetType());
 
   ColorPattern shadowColor(ToDeviceColor(aShadowColor));
   boxShadowDT->MaskSurface(shadowColor, aBlurMask, Point(0, 0));
   return boxShadowDT->Snapshot();
 }
 
 SourceSurface*
@@ -470,16 +475,20 @@ GetBlur(DrawTarget& aDT,
   RefPtr<SourceSurface> blurMask =
     CreateBlurMask(aRectSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice, aDT);
 
   if (!blurMask) {
     return nullptr;
   }
 
   RefPtr<SourceSurface> boxShadow = CreateBoxShadow(aDT, blurMask, aShadowColor);
+  if (!boxShadow) {
+    return nullptr;
+  }
+
   CacheBlur(aDT, minSize, aBlurRadius, aCornerRadii, aShadowColor, aExtendDestBy, boxShadow);
   return boxShadow;
 }
 
 void
 gfxAlphaBoxBlur::ShutdownBlurCache()
 {
   delete gBlurCache;