Bug 1027107 - Use fallible allocations in gfx::AlphaBoxBlur::Blur. r=Bas, a=sledru
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 09 Jul 2014 13:53:51 +1200
changeset 199719 27f25e1d82adc9b66e55b3a091e492b2522e15be
parent 199718 0d13dda8761b0338fe349e2f0d687982074bfb26
child 199720 ff83e05223eb57c19253506433181958892e60b0
child 199723 f05aff2961145b68b511e4d59dad92c6a8c6292b
push id3726
push userryanvm@gmail.com
push dateThu, 10 Jul 2014 12:56:47 +0000
treeherdermozilla-beta@27f25e1d82ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1027107
milestone31.0
Bug 1027107 - Use fallible allocations in gfx::AlphaBoxBlur::Blur. r=Bas, a=sledru
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);