Bug 965914 - Don't crash when we can't allocate a new surface in CloneAligned. r=Bas
authorMarkus Stange <mstange@themasta.com>
Tue, 04 Feb 2014 21:03:12 +0100
changeset 166808 51e86840de9bc91109d50c4d05c4533d8c1410b4
parent 166807 3bbf61b9d523a64725c4fbab85922c71bd0452f3
child 166809 5c04b296c127b188fe3a983322a6e54a1a1bc0bf
push id39285
push usermstange@themasta.com
push dateTue, 04 Feb 2014 20:03:27 +0000
treeherdermozilla-inbound@5c04b296c127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs965914
milestone30.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 965914 - Don't crash when we can't allocate a new surface in CloneAligned. r=Bas
gfx/2d/FilterNodeSoftware.cpp
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -230,17 +230,19 @@ CopyRect(DataSourceSurface* aSrc, DataSo
   }
 }
 
 TemporaryRef<DataSourceSurface>
 CloneAligned(DataSourceSurface* aSource)
 {
   RefPtr<DataSourceSurface> copy =
     Factory::CreateDataSourceSurface(aSource->GetSize(), aSource->GetFormat());
-  CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
+  if (copy) {
+    CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
+  }
   return copy;
 }
 
 static void
 FillRectWithPixel(DataSourceSurface *aSurface, const IntRect &aFillRect, IntPoint aPixelPos)
 {
   uint8_t* data = aSurface->GetData();
   uint8_t* sourcePixelData = data + DataOffset(aSurface, aPixelPos);
@@ -725,29 +727,30 @@ FilterNodeSoftware::GetInputDataSourceSu
     IntRect srcRect = aTransparencyPaddedSourceRect->Intersect(aRect);
     surface = GetDataSurfaceInRect(surface, surfaceRect, srcRect, EDGE_MODE_NONE);
     surfaceRect = srcRect;
   }
 
   RefPtr<DataSourceSurface> result =
     GetDataSurfaceInRect(surface, surfaceRect, aRect, aEdgeMode);
 
+  if (result &&
+      (result->Stride() != GetAlignedStride<16>(result->Stride()) ||
+       reinterpret_cast<uintptr_t>(result->GetData()) % 16 != 0)) {
+    // Align unaligned surface.
+    result = CloneAligned(result);
+  }
+
   if (!result) {
 #ifdef DEBUG_DUMP_SURFACES
     printf(" -- no input --</section>\n\n");
 #endif
     return nullptr;
   }
 
-  if (result->Stride() != GetAlignedStride<16>(result->Stride()) ||
-      reinterpret_cast<uintptr_t>(result->GetData()) % 16 != 0) {
-    // Align unaligned surface.
-    result = CloneAligned(result);
-  }
-
   SurfaceFormat currentFormat = result->GetFormat();
   if (DesiredFormat(currentFormat, aFormatHint) == SurfaceFormat::B8G8R8A8 &&
       currentFormat != SurfaceFormat::B8G8R8A8) {
     result = FilterProcessing::ConvertToB8G8R8A8(result);
   }
 
 #ifdef DEBUG_DUMP_SURFACES
   printf("<img src='"); DumpAsPNG(result); printf("'></section>");