Bug 1284117 - Make RasterImage and SourceBuffer handle input stream read errors. r=edwin
authorAndrew Osmond <aosmond@mozilla.com>
Thu, 13 Oct 2016 10:09:35 -0400
changeset 361680 518ab93137128a640a30c9e8b0617d80432e41a0
parent 361679 f9faf2a9c735fb2a7040eae2b4c5fbaa43486f74
child 361681 38ae3688a00bba02f5d47a65c5f58d84ef25b7bc
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1284117
milestone52.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 1284117 - Make RasterImage and SourceBuffer handle input stream read errors. r=edwin
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);