Bug 1318736 - Copy image file only if it's successfully decoded. r=tnikkel a=gchang
authorHector Zhao <bzhao@mozilla.com>
Fri, 02 Dec 2016 11:25:25 +0800
changeset 359128 2d1fa1d56e385da834601974ba2744c27f7b84cc
parent 359127 c63d33a0f879980cb056d3276232029d10ba59fb
child 359129 28be1a348351539bd5341c44120a0829d21a7a35
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, gchang
bugs1318736
milestone51.0
Bug 1318736 - Copy image file only if it's successfully decoded. r=tnikkel a=gchang MozReview-Commit-ID: DoTGyjUDzUh
dom/base/nsCopySupport.cpp
--- a/dom/base/nsCopySupport.cpp
+++ b/dom/base/nsCopySupport.cpp
@@ -584,16 +584,25 @@ static nsresult AppendDOMNode(nsITransfe
 #ifdef XP_WIN
 static nsresult AppendImagePromise(nsITransferable* aTransferable,
                                    imgIRequest* aImgRequest,
                                    nsIImageLoadingContent* aImageElement)
 {
   nsresult rv;
 
   NS_ENSURE_TRUE(aImgRequest, NS_OK);
+
+  uint32_t imageStatus;
+  rv = aImgRequest->GetImageStatus(&imageStatus);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!(imageStatus & imgIRequest::STATUS_FRAME_COMPLETE) ||
+      (imageStatus & imgIRequest::STATUS_ERROR)) {
+    return NS_OK;
+  }
+
   nsCOMPtr<nsINode> node = do_QueryInterface(aImageElement, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Fix the file extension in the URL if necessary
   nsCOMPtr<nsIMIMEService> mimeService =
     do_GetService(NS_MIMESERVICE_CONTRACTID);
   NS_ENSURE_TRUE(mimeService, NS_OK);