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 207798 54681c0522d06aff9df60260e97a215b6b3a4400
parent 207797 65562a267f08c5ccaf5aa6b994004109b9ce0d37
child 207799 c927922cb9551966e0038d2d0e74479c8d10886d
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1027107
milestone32.0a2
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);