Bug 1027107 - Use fallible allocations in gfx::AlphaBoxBlur::Blur. r=Bas
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 09 Jul 2014 13:53:51 +1200
changeset 192921 25e05badc128ca6d9236ae7cfe931a1ed38d0503
parent 192920 bd41dff8f47558272c1fe01a96e7596d05171a80
child 192922 cc20208a6eb4d425efa9489986150fced4d96304
push id45984
push usermwoodrow@mozilla.com
push dateWed, 09 Jul 2014 01:54:17 +0000
treeherdermozilla-inbound@25e05badc128 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1027107
milestone33.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 1027107 - Use fallible allocations in gfx::AlphaBoxBlur::Blur. r=Bas
gfx/2d/Blur.cpp
--- a/gfx/2d/Blur.cpp
+++ b/gfx/2d/Blur.cpp
@@ -493,17 +493,21 @@ AlphaBoxBlur::Blur(uint8_t* aData)
                               size.height + verticalLobes[0][0] + verticalLobes[1][1] + 1);
 
     if ((integralImageSize.width * integralImageSize.height) > (1 << 24)) {
       // Fallback to old blurring code when the surface is so large it may
       // overflow our integral image!
 
       // No need to use CheckedInt here - we have validated it in the constructor.
       size_t szB = stride * size.height;
-      uint8_t* tmpData = new uint8_t[szB];
+      uint8_t* tmpData = new (std::nothrow) uint8_t[szB];
+      if (!tmpData) {
+        return;
+      }
+
       memset(tmpData, 0, szB);
 
       uint8_t* a = aData;
       uint8_t* b = tmpData;
       if (mBlurRadius.width > 0) {
         BoxBlurHorizontal(a, b, horizontalLobes[0][0], horizontalLobes[0][1], stride, GetSize().height, mSkipRect);
         BoxBlurHorizontal(b, a, horizontalLobes[1][0], horizontalLobes[1][1], stride, GetSize().height, mSkipRect);
         BoxBlurHorizontal(a, b, horizontalLobes[2][0], horizontalLobes[2][1], stride, GetSize().height, mSkipRect);