Bug 1356580 - Better check of PMemoryStream actor creation in Blob code, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 18 Apr 2017 22:16:04 +0200
changeset 353589 603563fad0fe1e2d2fe4238cb0b251cae371b2c2
parent 353588 b0558476964426f0566a90e70fd1995acac57f2c
child 353590 bbd8e6ecf4a00d33736f1df5f906a6331467d966
push id89298
push useramarchesini@mozilla.com
push dateTue, 18 Apr 2017 20:16:22 +0000
treeherdermozilla-inbound@603563fad0fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1356580
milestone55.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 1356580 - Better check of PMemoryStream actor creation in Blob code, r=qdot
dom/file/ipc/Blob.cpp
--- a/dom/file/ipc/Blob.cpp
+++ b/dom/file/ipc/Blob.cpp
@@ -622,17 +622,19 @@ struct MOZ_STACK_CLASS CreateBlobImplMet
 template<class M>
 PMemoryStreamChild*
 SerializeInputStreamInChunks(nsIInputStream* aInputStream, uint64_t aLength,
                              M* aManager)
 {
   MOZ_ASSERT(aInputStream);
 
   PMemoryStreamChild* child = aManager->SendPMemoryStreamConstructor(aLength);
-  MOZ_ASSERT(child);
+  if (NS_WARN_IF(!child)) {
+    return nullptr;
+  }
 
   const uint64_t kMaxChunk = 1024 * 1024;
 
   while (aLength) {
     FallibleTArray<uint8_t> buffer;
 
     uint64_t size = XPCOM_MIN(aLength, kMaxChunk);
     if (NS_WARN_IF(!buffer.SetLength(size, fallible))) {
@@ -653,17 +655,19 @@ SerializeInputStreamInChunks(nsIInputStr
 
     MOZ_ASSERT(read <= size);
     aLength -= read;
 
     if (NS_WARN_IF(!buffer.SetLength(read, fallible))) {
       return nullptr;
     }
 
-    child->SendAddChunk(buffer);
+    if (NS_WARN_IF(!child->SendAddChunk(buffer))) {
+      return nullptr;
+    }
   }
 
   return child;
 }
 
 void
 DeleteStreamMemoryFromBlobDataStream(BlobDataStream& aStream)
 {