Bug 1167356 - Add return value checking for more instances of DataSourceSurface::Map. r=Bas, a=lizzard
authorAndrew Comminos <acomminos@mozilla.com>
Wed, 17 Jun 2015 15:40:34 -0400
changeset 267745 2a55a06804f5d1aa906d3e1c76de047d82f71dbd
parent 267744 06c3ceb5914083881e4ba817be9d152bf6257249
child 267746 34932cea5d16d9d1d6c208da82d216b5e0e5aa39
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, lizzard
bugs1167356
milestone39.0
Bug 1167356 - Add return value checking for more instances of DataSourceSurface::Map. r=Bas, a=lizzard
image/src/RasterImage.cpp
image/src/imgFrame.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -672,19 +672,20 @@ RasterImage::CopyFrame(uint32_t aWhichFr
     Factory::CreateDataSourceSurface(size,
                                      SurfaceFormat::B8G8R8A8,
                                      /* aZero = */ true);
   if (NS_WARN_IF(!surf)) {
     return nullptr;
   }
 
   DataSourceSurface::MappedSurface mapping;
-  DebugOnly<bool> success =
-    surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
-  NS_ASSERTION(success, "Failed to map surface");
+  if (NS_WARN_IF(!surf->Map(DataSourceSurface::MapType::WRITE, &mapping))) {
+    return nullptr;
+  }
+
   RefPtr<DrawTarget> target =
     Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      mapping.mData,
                                      size,
                                      mapping.mStride,
                                      SurfaceFormat::B8G8R8A8);
   if (!target) {
     gfxWarning() << "RasterImage::CopyFrame failed in CreateDrawTargetForData";
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -468,19 +468,21 @@ nsresult imgFrame::Optimize()
       return NS_OK;
 
     RefPtr<DataSourceSurface> surf =
       CreateLockedSurface(buf, mSize, optFormat);
     if (!surf)
       return NS_ERROR_OUT_OF_MEMORY;
 
     DataSourceSurface::MappedSurface mapping;
-    DebugOnly<bool> success =
-      surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
-    NS_ASSERTION(success, "Failed to map surface");
+    if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
+      gfxCriticalError() << "imgFrame::Optimize failed to map surface";
+      return NS_ERROR_FAILURE;
+    }
+
     RefPtr<DrawTarget> target =
       Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                        mapping.mData,
                                        mSize,
                                        mapping.mStride,
                                        optFormat);
 
     if (!target) {
@@ -872,19 +874,21 @@ imgFrame::Deoptimize()
       }
 
       RefPtr<DataSourceSurface> surf =
         CreateLockedSurface(buf, mSize, format);
       if (!surf)
         return NS_ERROR_OUT_OF_MEMORY;
 
       DataSourceSurface::MappedSurface mapping;
-      DebugOnly<bool> success =
-        surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
-      NS_ASSERTION(success, "Failed to map surface");
+      if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
+        gfxCriticalError() << "imgFrame::Deoptimize failed to map surface";
+        return NS_ERROR_FAILURE;
+      }
+
       RefPtr<DrawTarget> target =
         Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                          mapping.mData,
                                          mSize,
                                          mapping.mStride,
                                          format);
       if (!target) {
         gfxWarning() << "imgFrame::Deoptimize failed in CreateDrawTargetForData";