Bug 571074 - Mark nsITransferable.getTransferData as [must_use]. r=mats
authorTom Schuster <evilpies@gmail.com>
Fri, 04 Jan 2019 16:16:59 +0000
changeset 509656 2e4c5ef41c73f76499609a03c08e3d410a610c21
parent 509655 949d63540a2581f6296f733f30f5b28b0b140152
child 509657 8e2d7fcc07f51574c9b48f3641cdae95ae387197
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs571074
milestone66.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 571074 - Mark nsITransferable.getTransferData as [must_use]. r=mats Differential Revision: https://phabricator.services.mozilla.com/D13454
dom/base/nsContentAreaDragDrop.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
widget/cocoa/nsChildView.mm
widget/cocoa/nsClipboard.mm
widget/gtk/nsClipboard.cpp
widget/gtk/nsDragService.cpp
widget/nsITransferable.idl
widget/windows/nsDataObj.cpp
--- a/dom/base/nsContentAreaDragDrop.cpp
+++ b/dom/base/nsContentAreaDragDrop.cpp
@@ -213,46 +213,51 @@ nsContentAreaDragDropDataProvider::GetFl
   *aData = nullptr;
 
   nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
 
   if (strcmp(aFlavor, kFilePromiseMime) == 0) {
     // get the URI from the kFilePromiseURLMime flavor
     NS_ENSURE_ARG(aTransferable);
     nsCOMPtr<nsISupports> tmp;
-    aTransferable->GetTransferData(kFilePromiseURLMime, getter_AddRefs(tmp));
+    rv = aTransferable->GetTransferData(kFilePromiseURLMime,
+                                        getter_AddRefs(tmp));
+    NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsISupportsString> supportsString = do_QueryInterface(tmp);
     if (!supportsString) return NS_ERROR_FAILURE;
 
     nsAutoString sourceURLString;
     supportsString->GetData(sourceURLString);
     if (sourceURLString.IsEmpty()) return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsIURI> sourceURI;
     rv = NS_NewURI(getter_AddRefs(sourceURI), sourceURLString);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    aTransferable->GetTransferData(kFilePromiseDestFilename,
-                                   getter_AddRefs(tmp));
+    rv = aTransferable->GetTransferData(kFilePromiseDestFilename,
+                                        getter_AddRefs(tmp));
+    NS_ENSURE_SUCCESS(rv, rv);
     supportsString = do_QueryInterface(tmp);
     if (!supportsString) return NS_ERROR_FAILURE;
 
     nsAutoString targetFilename;
     supportsString->GetData(targetFilename);
     if (targetFilename.IsEmpty()) return NS_ERROR_FAILURE;
 
 #if defined(XP_MACOSX)
     // Use the image request's MIME type to ensure the filename's
     // extension is compatible with the OS's handler for this type.
     // If it isn't, or is missing, replace the extension with the
     // primary extension. On Mac, do this in the parent process
     // because sandboxing blocks access to MIME-handler info from
     // content processes.
     if (XRE_IsParentProcess()) {
-      aTransferable->GetTransferData(kImageRequestMime, getter_AddRefs(tmp));
+      rv = aTransferable->GetTransferData(kImageRequestMime,
+                                          getter_AddRefs(tmp));
+      NS_ENSURE_SUCCESS(rv, rv);
       supportsString = do_QueryInterface(tmp);
       if (!supportsString) return NS_ERROR_FAILURE;
 
       nsAutoString imageRequestMime;
       supportsString->GetData(imageRequestMime);
 
       // If we have a MIME type, check the extension is compatible
       if (!imageRequestMime.IsEmpty()) {
@@ -287,18 +292,19 @@ nsContentAreaDragDropDataProvider::GetFl
     // make the filename safe for the filesystem
     targetFilename.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS,
                                '-');
 #endif /* defined(XP_MACOSX) */
 
     // get the target directory from the kFilePromiseDirectoryMime
     // flavor
     nsCOMPtr<nsISupports> dirPrimitive;
-    aTransferable->GetTransferData(kFilePromiseDirectoryMime,
-                                   getter_AddRefs(dirPrimitive));
+    rv = aTransferable->GetTransferData(kFilePromiseDirectoryMime,
+                                        getter_AddRefs(dirPrimitive));
+    NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIFile> destDirectory = do_QueryInterface(dirPrimitive);
     if (!destDirectory) return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsIFile> file;
     rv = destDirectory->Clone(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
 
     file->Append(targetFilename);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1490,48 +1490,48 @@ nsresult HTMLEditor::PasteInternal(int32
 
   // also get additional html copy hints, if present
   nsAutoString contextStr, infoStr;
 
   // If we have our internal html flavor on the clipboard, there is special
   // context to use instead of cfhtml context.
   bool bHavePrivateHTMLFlavor = HavePrivateHTMLFlavor(clipboard);
   if (bHavePrivateHTMLFlavor) {
-    nsCOMPtr<nsISupports> contextDataObj, infoDataObj;
-    nsCOMPtr<nsISupportsString> textDataObj;
-
     nsCOMPtr<nsITransferable> contextTransferable =
         do_CreateInstance("@mozilla.org/widget/transferable;1");
     if (NS_WARN_IF(!contextTransferable)) {
       return NS_ERROR_FAILURE;
     }
     contextTransferable->Init(nullptr);
     contextTransferable->AddDataFlavor(kHTMLContext);
     clipboard->GetData(contextTransferable, aClipboardType);
-    contextTransferable->GetTransferData(kHTMLContext,
-                                         getter_AddRefs(contextDataObj));
+    nsCOMPtr<nsISupports> contextDataObj;
+    rv = contextTransferable->GetTransferData(kHTMLContext,
+                                              getter_AddRefs(contextDataObj));
+    if (NS_SUCCEEDED(rv) && contextDataObj) {
+      if (nsCOMPtr<nsISupportsString> str = do_QueryInterface(contextDataObj)) {
+        str->GetData(contextStr);
+      }
+    }
 
     nsCOMPtr<nsITransferable> infoTransferable =
         do_CreateInstance("@mozilla.org/widget/transferable;1");
     if (NS_WARN_IF(!infoTransferable)) {
       return NS_ERROR_FAILURE;
     }
     infoTransferable->Init(nullptr);
     infoTransferable->AddDataFlavor(kHTMLInfo);
     clipboard->GetData(infoTransferable, aClipboardType);
-    infoTransferable->GetTransferData(kHTMLInfo, getter_AddRefs(infoDataObj));
-
-    if (contextDataObj) {
-      textDataObj = do_QueryInterface(contextDataObj);
-      textDataObj->GetData(contextStr);
-    }
-
-    if (infoDataObj) {
-      textDataObj = do_QueryInterface(infoDataObj);
-      textDataObj->GetData(infoStr);
+    nsCOMPtr<nsISupports> infoDataObj;
+    rv = infoTransferable->GetTransferData(kHTMLInfo,
+                                           getter_AddRefs(infoDataObj));
+    if (NS_SUCCEEDED(rv) && infoDataObj) {
+      if (nsCOMPtr<nsISupportsString> str = do_QueryInterface(infoDataObj)) {
+        str->GetData(infoStr);
+      }
     }
   }
 
   rv = InsertFromTransferable(transferable, nullptr, contextStr, infoStr,
                               bHavePrivateHTMLFlavor, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1,16 +1,17 @@
 /* -*- Mode: objc; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 
 #include "mozilla/Logging.h"
+#include "mozilla/Unused.h"
 
 #include <unistd.h>
 #include <math.h>
 
 #include "nsChildView.h"
 #include "nsCocoaWindow.h"
 
 #include "mozilla/MiscEvents.h"
@@ -6252,18 +6253,18 @@ provideDataForType:(NSString*)aType
             continue;
           }
 
           item->SetTransferData(kFilePromiseDirectoryMime, macLocalFile);
 
           // Now request the kFilePromiseMime data, which will invoke the data
           // provider. If successful, the file will have been created.
           nsCOMPtr<nsISupports> fileDataPrimitive;
-          item->GetTransferData(kFilePromiseMime,
-                                getter_AddRefs(fileDataPrimitive));
+          Unused << item->GetTransferData(kFilePromiseMime,
+                                          getter_AddRefs(fileDataPrimitive));
         }
         CFRelease(urlRef);
         CFRelease(pboardRef);
 
         [aPasteboard setPropertyList:[pasteboardOutputDict valueForKey:curType]
                              forType:curType];
       }
     }
--- a/widget/cocoa/nsClipboard.mm
+++ b/widget/cocoa/nsClipboard.mm
@@ -557,17 +557,20 @@ nsClipboard::PasteboardDictFromTransfera
           [UTIHelper stringFromPboardType:kMozCustomTypesPboardType];
         [pasteboardOutputDict setObject:nativeData forKey:customType];
       }
     }
     else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
              flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) ||
              flavorStr.EqualsLiteral(kNativeImageMime)) {
       nsCOMPtr<nsISupports> transferSupports;
-      aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports));
+      rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports));
+      if (NS_FAILED(rv)) {
+        continue;
+      }
 
       nsCOMPtr<imgIContainer> image(do_QueryInterface(transferSupports));
       if (!image) {
         NS_WARNING("Image isn't an imgIContainer in transferable");
         continue;
       }
 
       RefPtr<SourceSurface> surface =
--- a/widget/gtk/nsClipboard.cpp
+++ b/widget/gtk/nsClipboard.cpp
@@ -430,17 +430,19 @@ void nsClipboard::SelectionGetEvent(GtkC
   GdkAtom selectionTarget = gtk_selection_data_get_target(aSelectionData);
 
   // Check to see if the selection data is some text type.
   if (gtk_targets_include_text(&selectionTarget, 1)) {
     // Try to convert our internal type into a text string.  Get
     // the transferable for this clipboard and try to get the
     // text/unicode type for it.
     rv = trans->GetTransferData("text/unicode", getter_AddRefs(item));
-    if (!item || NS_FAILED(rv)) return;
+    if (NS_FAILED(rv) || !item) {
+      return;
+    }
 
     nsCOMPtr<nsISupportsString> wideString;
     wideString = do_QueryInterface(item);
     if (!wideString) return;
 
     nsAutoString ucs2string;
     wideString->GetData(ucs2string);
     NS_ConvertUTF16toUTF8 utf8string(ucs2string);
@@ -479,17 +481,17 @@ void nsClipboard::SelectionGetEvent(GtkC
 
     gtk_selection_data_set_pixbuf(aSelectionData, pixbuf);
     g_object_unref(pixbuf);
     return;
   }
 
   if (selectionTarget == gdk_atom_intern(kHTMLMime, FALSE)) {
     rv = trans->GetTransferData(kHTMLMime, getter_AddRefs(item));
-    if (!item || NS_FAILED(rv)) {
+    if (NS_FAILED(rv) || !item) {
       return;
     }
 
     nsCOMPtr<nsISupportsString> wideString;
     wideString = do_QueryInterface(item);
     if (!wideString) {
       return;
     }
@@ -509,17 +511,17 @@ void nsClipboard::SelectionGetEvent(GtkC
 
   // Try to match up the selection data target to something our
   // transferable provides.
   gchar *target_name = gdk_atom_name(selectionTarget);
   if (!target_name) return;
 
   rv = trans->GetTransferData(target_name, getter_AddRefs(item));
   // nothing found?
-  if (!item || NS_FAILED(rv)) {
+  if (NS_FAILED(rv) || !item) {
     g_free(target_name);
     return;
   }
 
   void *primitive_data = nullptr;
   uint32_t dataLen = 0;
   nsPrimitiveHelpers::CreateDataFromPrimitive(nsDependentCString(target_name),
                                               item, &primitive_data, &dataLen);
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -1558,20 +1558,26 @@ void nsDragService::SourceBeginDrag(GdkD
 
   nsTArray<nsCString> flavors;
   nsresult rv = transferable->FlavorsTransferableCanImport(flavors);
   NS_ENSURE_SUCCESS(rv, );
 
   for (uint32_t i = 0; i < flavors.Length(); ++i) {
     if (flavors[i].EqualsLiteral(kFilePromiseDestFilename)) {
       nsCOMPtr<nsISupports> data;
-      transferable->GetTransferData(kFilePromiseDestFilename,
-                                    getter_AddRefs(data));
+      rv = transferable->GetTransferData(kFilePromiseDestFilename,
+                                         getter_AddRefs(data));
+      if (NS_FAILED(rv)) {
+        return;
+      }
+
       nsCOMPtr<nsISupportsString> fileName = do_QueryInterface(data);
-      if (!fileName) return;
+      if (!fileName) {
+        return;
+      }
 
       nsAutoString fileNameStr;
       fileName->GetData(fileNameStr);
 
       nsCString fileNameCStr;
       CopyUTF16toUTF8(fileNameStr, fileNameCStr);
 
       GdkAtom property = gdk_atom_intern(gXdndDirectSaveType, FALSE);
--- a/widget/nsITransferable.idl
+++ b/widget/nsITransferable.idl
@@ -120,23 +120,22 @@ interface nsITransferable : nsISupports
 
   /**
     * Computes a list of flavors that the transferable can export, either
     * through intrinsic knowledge or output data converters.
     */
   Array<ACString> flavorsTransferableCanExport();
 
   /**
-    * Given a flavor retrieve the data. 
+    * Given a flavor retrieve the data.
     *
     * @param  aFlavor (in parameter) the flavor of data to retrieve
     * @param  aData the data. Some variant of class in nsISupportsPrimitives.idl
-    * @param  aDataLen the length of the data
     */
-  void getTransferData(in string aFlavor, out nsISupports aData);
+  [must_use] void getTransferData(in string aFlavor, out nsISupports aData);
 
   /**
     * Returns the best flavor in the transferable, given those that have
     * been added to it with |AddFlavor()|
     *
     * @param  aFlavor (out parameter) the flavor of data that was retrieved
     * @param  aData the data. Some variant of class in nsISupportsPrimitives.idl
     */
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -804,77 +804,79 @@ HRESULT nsDataObj::AddGetFormat(FORMATET
 // GetDIB
 //
 // Someone is asking for a bitmap. The data in the transferable will be a
 // straight imgIContainer, so just QI it.
 //
 HRESULT
 nsDataObj::GetDib(const nsACString& inFlavor, FORMATETC& aFormat,
                   STGMEDIUM& aSTG) {
-  ULONG result = E_FAIL;
   nsCOMPtr<nsISupports> genericDataWrapper;
-  mTransferable->GetTransferData(PromiseFlatCString(inFlavor).get(),
-                                 getter_AddRefs(genericDataWrapper));
-  nsCOMPtr<imgIContainer> image(do_QueryInterface(genericDataWrapper));
-  if (image) {
-    nsCOMPtr<imgITools> imgTools =
-        do_CreateInstance("@mozilla.org/image/tools;1");
+  if (NS_FAILED(
+          mTransferable->GetTransferData(PromiseFlatCString(inFlavor).get(),
+                                         getter_AddRefs(genericDataWrapper)))) {
+    return E_FAIL;
+  }
+
+  nsCOMPtr<imgIContainer> image = do_QueryInterface(genericDataWrapper);
+  if (!image) {
+    return E_FAIL;
+  }
 
-    nsAutoString options;
-    if (aFormat.cfFormat == CF_DIBV5) {
-      options.AppendLiteral("version=5");
-    } else {
-      options.AppendLiteral("version=3");
-    }
+  nsCOMPtr<imgITools> imgTools =
+      do_CreateInstance("@mozilla.org/image/tools;1");
 
-    nsCOMPtr<nsIInputStream> inputStream;
-    nsresult rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP),
-                                        options, getter_AddRefs(inputStream));
-    if (NS_FAILED(rv) || !inputStream) {
-      return E_FAIL;
-    }
+  nsAutoString options;
+  if (aFormat.cfFormat == CF_DIBV5) {
+    options.AppendLiteral("version=5");
+  } else {
+    options.AppendLiteral("version=3");
+  }
 
-    nsCOMPtr<imgIEncoder> encoder = do_QueryInterface(inputStream);
-    if (!encoder) {
-      return E_FAIL;
-    }
+  nsCOMPtr<nsIInputStream> inputStream;
+  nsresult rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP),
+                                      options, getter_AddRefs(inputStream));
+  if (NS_FAILED(rv) || !inputStream) {
+    return E_FAIL;
+  }
 
-    uint32_t size = 0;
-    rv = encoder->GetImageBufferUsed(&size);
-    if (NS_FAILED(rv) || size <= BFH_LENGTH) {
-      return E_FAIL;
-    }
+  nsCOMPtr<imgIEncoder> encoder = do_QueryInterface(inputStream);
+  if (!encoder) {
+    return E_FAIL;
+  }
 
-    char* src = nullptr;
-    rv = encoder->GetImageBuffer(&src);
-    if (NS_FAILED(rv) || !src) {
-      return E_FAIL;
-    }
+  uint32_t size = 0;
+  rv = encoder->GetImageBufferUsed(&size);
+  if (NS_FAILED(rv) || size <= BFH_LENGTH) {
+    return E_FAIL;
+  }
 
-    // We don't want the file header.
-    src += BFH_LENGTH;
-    size -= BFH_LENGTH;
+  char* src = nullptr;
+  rv = encoder->GetImageBuffer(&src);
+  if (NS_FAILED(rv) || !src) {
+    return E_FAIL;
+  }
 
-    HGLOBAL glob = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, size);
-    if (!glob) {
-      DWORD err = ::GetLastError();
-      return E_FAIL;
-    }
+  // We don't want the file header.
+  src += BFH_LENGTH;
+  size -= BFH_LENGTH;
 
-    char* dst = (char*)::GlobalLock(glob);
-    ::CopyMemory(dst, src, size);
-    ::GlobalUnlock(glob);
+  HGLOBAL glob = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, size);
+  if (!glob) {
+    DWORD err = ::GetLastError();
+    return E_FAIL;
+  }
 
-    aSTG.hGlobal = glob;
-    aSTG.tymed = TYMED_HGLOBAL;
-    result = S_OK;
-  } else {
-    NS_WARNING("Definitely not an image on clipboard");
-  }
-  return result;
+  char* dst = (char*)::GlobalLock(glob);
+  ::CopyMemory(dst, src, size);
+  ::GlobalUnlock(glob);
+
+  aSTG.hGlobal = glob;
+  aSTG.tymed = TYMED_HGLOBAL;
+  return S_OK;
 }
 
 //
 // GetFileDescriptor
 //
 
 HRESULT
 nsDataObj ::GetFileDescriptor(FORMATETC& aFE, STGMEDIUM& aSTG,
@@ -1266,18 +1268,21 @@ HRESULT nsDataObj::GetText(const nsACStr
   const nsPromiseFlatCString& flat = PromiseFlatCString(aDataFlavor);
   if (aDataFlavor.EqualsLiteral("text/plain"))
     flavorStr = kUnicodeMime;
   else
     flavorStr = flat.get();
 
   // NOTE: CreateDataFromPrimitive creates new memory, that needs to be deleted
   nsCOMPtr<nsISupports> genericDataWrapper;
-  mTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper));
-  if (!genericDataWrapper) return E_FAIL;
+  nsresult rv = mTransferable->GetTransferData(
+      flavorStr, getter_AddRefs(genericDataWrapper));
+  if (NS_FAILED(rv) || !genericDataWrapper) {
+    return E_FAIL;
+  }
 
   uint32_t len;
   nsPrimitiveHelpers::CreateDataFromPrimitive(nsDependentCString(flavorStr),
                                               genericDataWrapper, &data, &len);
   if (!data) return E_FAIL;
 
   HGLOBAL hGlobalMemory = nullptr;
 
@@ -1372,17 +1377,20 @@ HRESULT nsDataObj::GetFile(FORMATETC& aF
   }
   return E_FAIL;
 }
 
 HRESULT nsDataObj::DropFile(FORMATETC& aFE, STGMEDIUM& aSTG) {
   nsresult rv;
   nsCOMPtr<nsISupports> genericDataWrapper;
 
-  mTransferable->GetTransferData(kFileMime, getter_AddRefs(genericDataWrapper));
+  if (NS_FAILED(mTransferable->GetTransferData(
+          kFileMime, getter_AddRefs(genericDataWrapper)))) {
+    return E_FAIL;
+  }
   nsCOMPtr<nsIFile> file(do_QueryInterface(genericDataWrapper));
   if (!file) return E_FAIL;
 
   aSTG.tymed = TYMED_HGLOBAL;
   aSTG.pUnkForRelease = nullptr;
 
   nsAutoString path;
   rv = file->GetPath(path);
@@ -1421,18 +1429,20 @@ HRESULT nsDataObj::DropFile(FORMATETC& a
   return S_OK;
 }
 
 HRESULT nsDataObj::DropImage(FORMATETC& aFE, STGMEDIUM& aSTG) {
   nsresult rv;
   if (!mCachedTempFile) {
     nsCOMPtr<nsISupports> genericDataWrapper;
 
-    mTransferable->GetTransferData(kNativeImageMime,
-                                   getter_AddRefs(genericDataWrapper));
+    if (NS_FAILED(mTransferable->GetTransferData(
+            kNativeImageMime, getter_AddRefs(genericDataWrapper)))) {
+      return E_FAIL;
+    }
     nsCOMPtr<imgIContainer> image(do_QueryInterface(genericDataWrapper));
     if (!image) return E_FAIL;
 
     nsCOMPtr<imgITools> imgTools =
         do_CreateInstance("@mozilla.org/image/tools;1");
     nsCOMPtr<nsIInputStream> inputStream;
     rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP),
                                NS_LITERAL_STRING("version=3"),
@@ -1936,31 +1946,33 @@ nsDataObj::ExtractUniformResourceLocator
 HRESULT nsDataObj::GetDownloadDetails(nsIURI** aSourceURI,
                                       nsAString& aFilename) {
   *aSourceURI = nullptr;
 
   NS_ENSURE_TRUE(mTransferable, E_FAIL);
 
   // get the URI from the kFilePromiseURLMime flavor
   nsCOMPtr<nsISupports> urlPrimitive;
-  mTransferable->GetTransferData(kFilePromiseURLMime,
-                                 getter_AddRefs(urlPrimitive));
+  nsresult rv = mTransferable->GetTransferData(kFilePromiseURLMime,
+                                               getter_AddRefs(urlPrimitive));
+  NS_ENSURE_SUCCESS(rv, E_FAIL);
   nsCOMPtr<nsISupportsString> srcUrlPrimitive = do_QueryInterface(urlPrimitive);
   NS_ENSURE_TRUE(srcUrlPrimitive, E_FAIL);
 
   nsAutoString srcUri;
   srcUrlPrimitive->GetData(srcUri);
   if (srcUri.IsEmpty()) return E_FAIL;
   nsCOMPtr<nsIURI> sourceURI;
   NS_NewURI(getter_AddRefs(sourceURI), srcUri);
 
   nsAutoString srcFileName;
   nsCOMPtr<nsISupports> fileNamePrimitive;
-  mTransferable->GetTransferData(kFilePromiseDestFilename,
-                                 getter_AddRefs(fileNamePrimitive));
+  rv = mTransferable->GetTransferData(kFilePromiseDestFilename,
+                                      getter_AddRefs(fileNamePrimitive));
+  NS_ENSURE_SUCCESS(rv, E_FAIL);
   nsCOMPtr<nsISupportsString> srcFileNamePrimitive =
       do_QueryInterface(fileNamePrimitive);
   if (srcFileNamePrimitive) {
     srcFileNamePrimitive->GetData(srcFileName);
   } else {
     nsCOMPtr<nsIURL> sourceURL = do_QueryInterface(sourceURI);
     if (!sourceURL) return E_FAIL;