Bug 571074 - Mark nsITransferable.getTransferData as [must_use]. r=mats
☠☠ backed out by 1e64f8c3f949 ☠ ☠
authorTom Schuster <evilpies@gmail.com>
Thu, 29 Nov 2018 21:57:40 +0000
changeset 508091 f9900ac6071c17ff7af3ccfaf2a8ce02ea66cffc
parent 508090 6b447ab87004213505fbdcb0d2538a2634550737
child 508092 76a737a5a6e94e14b5fad10ca62ab259a27e2615
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs571074
milestone65.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
dom/base/nsContentUtils.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
@@ -236,33 +236,36 @@ 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;
@@ -270,18 +273,19 @@ nsContentAreaDragDropDataProvider::GetFl
 #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
@@ -319,18 +323,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);
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -8105,17 +8105,20 @@ nsContentUtils::TransferableToIPCTransfe
 
     for (uint32_t j = 0; j < flavorList.Length(); ++j) {
       nsCString& flavorStr = flavorList[j];
       if (!flavorStr.Length()) {
         continue;
       }
 
       nsCOMPtr<nsISupports> data;
-      aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(data));
+      if (NS_FAILED(aTransferable->GetTransferData(flavorStr.get(),
+                                                   getter_AddRefs(data)))) {
+        continue;
+      }
 
       nsCOMPtr<nsISupportsString> text = do_QueryInterface(data);
       nsCOMPtr<nsISupportsCString> ctext = do_QueryInterface(data);
       if (text) {
         nsAutoString dataAsString;
         text->GetData(dataAsString);
         IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
         item->flavor() = flavorStr;
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1590,29 +1590,35 @@ HTMLEditor::PasteInternal(int32_t aClipb
     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));
+    rv = contextTransferable->GetTransferData(kHTMLContext,
+                                              getter_AddRefs(contextDataObj));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
 
     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));
+    rv = infoTransferable->GetTransferData(kHTMLInfo,
+                                           getter_AddRefs(infoDataObj));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
 
     if (contextDataObj) {
       textDataObj = do_QueryInterface(contextDataObj);
       textDataObj->GetData(contextStr);
     }
 
     if (infoDataObj) {
       textDataObj = do_QueryInterface(infoDataObj);
--- 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"
@@ -6251,18 +6252,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
@@ -477,18 +477,19 @@ nsClipboard::SelectionGetEvent(GtkClipbo
     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))
+        if (NS_FAILED(rv) || !item) {
             return;
+        }
 
         nsCOMPtr<nsISupportsString> wideString;
         wideString = do_QueryInterface(item);
         if (!wideString)
             return;
 
         nsAutoString ucs2string;
         wideString->GetData(ucs2string);
@@ -528,17 +529,17 @@ nsClipboard::SelectionGetEvent(GtkClipbo
 
         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;
         }
@@ -559,17 +560,17 @@ nsClipboard::SelectionGetEvent(GtkClipbo
     // 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
@@ -1734,21 +1734,26 @@ nsDragService::SourceBeginDrag(GdkDragCo
 
     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)
+            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
@@ -126,17 +126,17 @@ interface nsITransferable : nsISupports
 
   /**
     * 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
@@ -892,75 +892,77 @@ HRESULT nsDataObj::AddGetFormat(FORMATET
 // 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;
+  }
+
+  nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
 
-    nsAutoString options;
-    if (aFormat.cfFormat == CF_DIBV5) {
-      options.AppendLiteral("version=5");
-    } else {
-      options.AppendLiteral("version=3");
-    }
+  nsAutoString options;
+  if (aFormat.cfFormat == CF_DIBV5) {
+    options.AppendLiteral("version=5");
+  } else {
+    options.AppendLiteral("version=3");
+  }
 
-    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;
-    }
-
-    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
 //
 
@@ -1369,19 +1371,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 )
+  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;
@@ -1479,17 +1483,19 @@ 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;
@@ -1532,17 +1538,20 @@ HRESULT nsDataObj::DropFile(FORMATETC& a
 }
 
 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"),
@@ -2091,30 +2100,32 @@ HRESULT nsDataObj::GetDownloadDetails(ns
                                       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;