Bug 1284117 - Make RasterImage and SourceBuffer handle input stream read errors. r=edwin, a=gchang
authorAndrew Osmond <aosmond@mozilla.com>
Thu, 13 Oct 2016 10:09:35 -0400
changeset 358722 ee87ff2bd4f55ada05e105256e38c2ea9a79a4c1
parent 358721 b5b6afc2af1d1b7702274b0be1cad9f062ba54a4
child 358723 825c2ee219dcb28bd07727c2cdec08c749ce045d
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)
reviewersedwin, gchang
bugs1284117
milestone51.0a2
Bug 1284117 - Make RasterImage and SourceBuffer handle input stream read errors. r=edwin, a=gchang
image/RasterImage.cpp
image/SourceBuffer.cpp
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -943,22 +943,19 @@ RasterImage::NotifyForLoadEvent(Progress
 nsresult
 RasterImage::OnImageDataAvailable(nsIRequest*,
                                   nsISupports*,
                                   nsIInputStream* aInputStream,
                                   uint64_t,
                                   uint32_t aCount)
 {
   nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount);
-  MOZ_ASSERT(rv == NS_OK || rv == NS_ERROR_OUT_OF_MEMORY);
-
-  if (MOZ_UNLIKELY(rv == NS_ERROR_OUT_OF_MEMORY)) {
+  if (NS_FAILED(rv)) {
     DoError();
   }
-
   return rv;
 }
 
 nsresult
 RasterImage::SetSourceSizeHint(uint32_t aSizeHint)
 {
   return mSourceBuffer->ExpectLength(aSizeHint);
 }
--- a/image/SourceBuffer.cpp
+++ b/image/SourceBuffer.cpp
@@ -446,21 +446,20 @@ AppendToSourceBuffer(nsIInputStream*,
 
 nsresult
 SourceBuffer::AppendFromInputStream(nsIInputStream* aInputStream,
                                     uint32_t aCount)
 {
   uint32_t bytesRead;
   nsresult rv = aInputStream->ReadSegments(AppendToSourceBuffer, this,
                                            aCount, &bytesRead);
-
-  MOZ_ASSERT(bytesRead == aCount || rv == NS_ERROR_OUT_OF_MEMORY,
-             "AppendToSourceBuffer should consume everything unless "
-             "we run out of memory");
-
+  if (!NS_WARN_IF(NS_FAILED(rv))) {
+    MOZ_ASSERT(bytesRead == aCount,
+               "AppendToSourceBuffer should consume everything");
+  }
   return rv;
 }
 
 void
 SourceBuffer::Complete(nsresult aStatus)
 {
   MutexAutoLock lock(mMutex);