Bug 1277122 - Add missing null checks for pixman_image_create_bits(). r=seth,lsalzman.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 01 Jun 2016 14:27:30 +1000
changeset 341054 50e32be6552151fd71dd828b30b24749b5fbf4d4
parent 341053 23fde8ecfa91aeaa071bb19165a999b8606008f1
child 341055 b6db2e11244e06e2563e7444709060cd9ea90e9f
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, lsalzman
bugs1277122
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1277122 - Add missing null checks for pixman_image_create_bits(). r=seth,lsalzman.
gfx/2d/DrawTargetCairo.cpp
image/FrameAnimator.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1955,21 +1955,27 @@ DrawTarget::Draw3DTransformedSurface(Sou
     return false;
   }
 
   // Wrap the surfaces in pixman images and do the transform.
   pixman_image_t* dst =
     pixman_image_create_bits(PIXMAN_a8r8g8b8,
                              xformBounds.width, xformBounds.height,
                              (uint32_t*)dstSurf->GetData(), dstSurf->Stride());
+  if (!dst) {
+    return false;
+  }
   pixman_image_t* src =
     pixman_image_create_bits(srcFormat,
                              srcSurf->GetSize().width, srcSurf->GetSize().height,
                              (uint32_t*)srcMap.GetData(), srcMap.GetStride());
-  MOZ_ASSERT(src && dst, "Failed to create pixman images?");
+  if (!src) {
+    pixman_image_unref(dst);
+    return false;
+  }
 
   pixman_image_set_filter(src, PIXMAN_FILTER_BILINEAR, nullptr, 0);
   pixman_image_set_transform(src, &xform);
 
   pixman_image_composite32(PIXMAN_OP_SRC,
                            src, nullptr, dst,
                            0, 0, 0, 0, 0, 0,
                            xformBounds.width, xformBounds.height);
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -803,22 +803,29 @@ FrameAnimator::DrawFrameTo(const uint8_t
     }
   } else {
     pixman_image_t* src =
       pixman_image_create_bits(
           aSrcHasAlpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
           aSrcRect.width, aSrcRect.height,
           reinterpret_cast<uint32_t*>(const_cast<uint8_t*>(aSrcData)),
           aSrcRect.width * 4);
+    if (!src) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
     pixman_image_t* dst =
       pixman_image_create_bits(PIXMAN_a8r8g8b8,
                                aDstRect.width,
                                aDstRect.height,
                                reinterpret_cast<uint32_t*>(aDstPixels),
                                aDstRect.width * 4);
+    if (!dst) {
+      pixman_image_unref(src);
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
 
     auto op = aBlendMethod == BlendMethod::SOURCE ? PIXMAN_OP_SRC
                                                   : PIXMAN_OP_OVER;
     pixman_image_composite32(op,
                              src,
                              nullptr,
                              dst,
                              0, 0,