Bug 1076825 - Don't crash release builds if allocating the buffer on white failed in RotatedBuffer.cpp. r=Bas, a=sledru
☠☠ backed out by 1233c159ab6d ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Mon, 06 Oct 2014 14:37:57 +0200
changeset 290434 d89ec5b69c012c74e975fc90500c477af3e921db
parent 290433 df37248fafcb578ff70317dbb7ab42df712edf7a
child 290435 9bf2a5b5162ddf0fe7a5f2c576bcb7a1ae78f5fb
push id218
push userryanvm@gmail.com
push dateWed, 16 Dec 2015 22:58:33 +0000
reviewersBas, sledru
bugs1076825
milestone33.0
Bug 1076825 - Don't crash release builds if allocating the buffer on white failed in RotatedBuffer.cpp. r=Bas, a=sledru
gfx/layers/RotatedBuffer.cpp
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -712,16 +712,22 @@ RotatedContentBuffer::BorrowDrawTargetFo
   }
   if (result->GetBackendType() == BackendType::DIRECT2D ||
       result->GetBackendType() == BackendType::DIRECT2D1_1) {
     drawPtr->SimplifyOutwardByArea(100 * 100);
   }
 
   if (aPaintState.mMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
     MOZ_ASSERT(mDTBuffer && mDTBufferOnWhite);
+    if (!mDTBuffer || !mDTBufferOnWhite) {
+      // This can happen in release builds if allocating one of the two buffers
+      // failed. This is pretty bad and the reason for the failure is already
+      // reported through gfxCriticalError.
+      return nullptr;
+    }
     nsIntRegionRectIterator iter(*drawPtr);
     const nsIntRect *iterRect;
     while ((iterRect = iter.Next())) {
       mDTBuffer->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
                           ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
       mDTBufferOnWhite->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
                                  ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
     }