Bug 1157193, fix null pointer check when dragging images, r=smaug
authorNeil Deakin <neil@mozilla.com>
Wed, 22 Apr 2015 15:18:22 -0400
changeset 240594 8bcdac2a7ad1fcddfdf451f1e5dda08bb3e468c0
parent 240593 68fe0894bb09d008d7c027aab9689cfe469f4e5a
child 240595 8ee491cacbb930c37cd02f6b4d50b4d135f3f095
push id28636
push userkwierso@gmail.com
push dateThu, 23 Apr 2015 00:16:12 +0000
treeherdermozilla-central@a5af73b32ac8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1157193
milestone40.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 1157193, fix null pointer check when dragging images, r=smaug
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -7298,34 +7298,35 @@ nsContentUtils::TransferableToIPCTransfe
           }
 
           // Images to be placed on the clipboard are imgIContainers.
           nsCOMPtr<imgIContainer> image(do_QueryInterface(data));
           if (image) {
             RefPtr<mozilla::gfx::SourceSurface> surface =
               image->GetFrame(imgIContainer::FRAME_CURRENT,
                               imgIContainer::FLAG_SYNC_DECODE);
-
-            mozilla::RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
-              surface->GetDataSurface();
-            size_t length;
-            int32_t stride;
-            mozilla::UniquePtr<char[]> surfaceData =
-              nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
-            
-            IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
-            item->flavor() = nsCString(flavorStr);
-            item->data() = nsCString(surfaceData.get(), length);
-
-            IPCDataTransferImage& imageDetails = item->imageDetails();
-            mozilla::gfx::IntSize size = dataSurface->GetSize();
-            imageDetails.width() = size.width;
-            imageDetails.height() = size.height;
-            imageDetails.stride() = stride;
-            imageDetails.format() = static_cast<uint8_t>(dataSurface->GetFormat());
+            if (surface) {
+              mozilla::RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
+                surface->GetDataSurface();
+              size_t length;
+              int32_t stride;
+              mozilla::UniquePtr<char[]> surfaceData =
+                nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
+              
+              IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
+              item->flavor() = nsCString(flavorStr);
+              item->data() = nsCString(surfaceData.get(), length);
+
+              IPCDataTransferImage& imageDetails = item->imageDetails();
+              mozilla::gfx::IntSize size = dataSurface->GetSize();
+              imageDetails.width() = size.width;
+              imageDetails.height() = size.height;
+              imageDetails.stride() = stride;
+              imageDetails.format() = static_cast<uint8_t>(dataSurface->GetFormat());
+            }
 
             continue;
           }
 
           // Otherwise, handle this as a file.
           nsCOMPtr<FileImpl> fileImpl;
           nsCOMPtr<nsIFile> file = do_QueryInterface(data);
           if (file) {