Bug 1538812 - Remove the dangerous default 'NS_ASSIGNMENT_DEPEND' of argument 'assignment' on NS_NewByteInputStream to let it be defined expicitly and thus visibly, r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Wed, 03 Apr 2019 11:39:41 +0000
changeset 526561 6e3fe092063699aed075b0db15e89c7c80285f93
parent 526560 8f1ab2cf557e21edbd9a16692d965165eb752d4a
child 526562 a001a531c01e96c01e755676e9f45480ef058742
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1538812
milestone68.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 1538812 - Remove the dangerous default 'NS_ASSIGNMENT_DEPEND' of argument 'assignment' on NS_NewByteInputStream to let it be defined expicitly and thus visibly, r=michal Differential Revision: https://phabricator.services.mozilla.com/D25462
dom/xhr/XMLHttpRequestMainThread.cpp
modules/libjar/zipwriter/nsDeflateConverter.cpp
modules/libjar/zipwriter/nsZipDataStream.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
toolkit/components/extensions/webrequest/StreamFilterParent.cpp
xpcom/io/nsStringStream.h
xpcom/tests/gtest/TestSnappyStreams.cpp
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -1531,17 +1531,18 @@ nsresult XMLHttpRequestMainThread::Strea
   if (xmlHttpRequest->mFlagParseBody) {
     // Give the same data to the parser.
 
     // We need to wrap the data in a new lightweight stream and pass that
     // to the parser, because calling ReadSegments() recursively on the same
     // stream is not supported.
     nsCOMPtr<nsIInputStream> copyStream;
     rv = NS_NewByteInputStream(getter_AddRefs(copyStream),
-                               MakeSpan(fromRawSegment, count));
+                               MakeSpan(fromRawSegment, count),
+                               NS_ASSIGNMENT_DEPEND);
 
     if (NS_SUCCEEDED(rv) && xmlHttpRequest->mXMLParserStreamListener) {
       NS_ASSERTION(copyStream, "NS_NewByteInputStream lied");
       nsresult parsingResult =
           xmlHttpRequest->mXMLParserStreamListener->OnDataAvailable(
               xmlHttpRequest->mChannel, copyStream, toOffset, count);
 
       // No use to continue parsing if we failed here, but we
--- a/modules/libjar/zipwriter/nsDeflateConverter.cpp
+++ b/modules/libjar/zipwriter/nsDeflateConverter.cpp
@@ -152,17 +152,18 @@ nsresult nsDeflateConverter::PushAvailab
                                                nsISupports *aContext) {
   uint32_t bytesToWrite = sizeof(mWriteBuffer) - mZstream.avail_out;
   // We don't need to do anything if there isn't any data
   if (bytesToWrite == 0) return NS_OK;
 
   MOZ_ASSERT(bytesToWrite <= INT32_MAX);
   nsCOMPtr<nsIInputStream> stream;
   nsresult rv = NS_NewByteInputStream(
-      getter_AddRefs(stream), MakeSpan((char *)mWriteBuffer, bytesToWrite));
+      getter_AddRefs(stream), MakeSpan((char *)mWriteBuffer, bytesToWrite),
+      NS_ASSIGNMENT_DEPEND);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mListener->OnDataAvailable(aRequest, stream, mOffset, bytesToWrite);
 
   // now set the state for 'deflate'
   mZstream.next_out = mWriteBuffer;
   mZstream.avail_out = sizeof(mWriteBuffer);
 
--- a/modules/libjar/zipwriter/nsZipDataStream.cpp
+++ b/modules/libjar/zipwriter/nsZipDataStream.cpp
@@ -112,18 +112,18 @@ inline nsresult nsZipDataStream::Complet
 nsresult nsZipDataStream::ProcessData(nsIRequest *aRequest,
                                       nsISupports *aContext, char *aBuffer,
                                       uint64_t aOffset, uint32_t aCount) {
   mHeader->mCRC = crc32(
       mHeader->mCRC, reinterpret_cast<const unsigned char *>(aBuffer), aCount);
 
   MOZ_ASSERT(aCount <= INT32_MAX);
   nsCOMPtr<nsIInputStream> stream;
-  nsresult rv =
-      NS_NewByteInputStream(getter_AddRefs(stream), MakeSpan(aBuffer, aCount));
+  nsresult rv = NS_NewByteInputStream(
+      getter_AddRefs(stream), MakeSpan(aBuffer, aCount), NS_ASSIGNMENT_DEPEND);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mOutput->OnDataAvailable(aRequest, stream, aOffset, aCount);
   mHeader->mUSize += aCount;
 
   return rv;
 }
 
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -373,17 +373,18 @@ nsresult nsHttpTransaction::Init(
       LOG3(("ObserveActivity failed (%08x)", static_cast<uint32_t>(rv)));
     }
   }
 
   // Create a string stream for the request header buf (the stream holds
   // a non-owning reference to the request header data, so we MUST keep
   // mReqHeaderBuf around).
   nsCOMPtr<nsIInputStream> headers;
-  rv = NS_NewByteInputStream(getter_AddRefs(headers), mReqHeaderBuf);
+  rv = NS_NewByteInputStream(getter_AddRefs(headers), mReqHeaderBuf,
+                             NS_ASSIGNMENT_DEPEND);
   if (NS_FAILED(rv)) return rv;
 
   mHasRequestBody = !!requestBody;
   if (mHasRequestBody && !requestContentLength) {
     mHasRequestBody = false;
   }
 
   requestContentLength += mReqHeaderBuf.Length();
--- a/toolkit/components/extensions/webrequest/StreamFilterParent.cpp
+++ b/toolkit/components/extensions/webrequest/StreamFilterParent.cpp
@@ -356,17 +356,18 @@ void StreamFilterParent::WriteMove(Data&
 }
 
 nsresult StreamFilterParent::Write(Data& aData) {
   AssertIsIOThread();
 
   nsCOMPtr<nsIInputStream> stream;
   nsresult rv = NS_NewByteInputStream(
       getter_AddRefs(stream),
-      MakeSpan(reinterpret_cast<char*>(aData.Elements()), aData.Length()));
+      MakeSpan(reinterpret_cast<char*>(aData.Elements()), aData.Length()),
+      NS_ASSIGNMENT_DEPEND);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv =
       mOrigListener->OnDataAvailable(mChannel, stream, mOffset, aData.Length());
   NS_ENSURE_SUCCESS(rv, rv);
 
   mOffset += aData.Length();
   return NS_OK;
--- a/xpcom/io/nsStringStream.h
+++ b/xpcom/io/nsStringStream.h
@@ -42,19 +42,19 @@
  *
  * If aAssignment is NS_ASSIGNMENT_ADOPT, then the resulting stream refers
  * directly to the given buffer (aStringToRead) and will free aStringToRead
  * once the stream is closed.
  *
  * If aLength is less than zero, then the length of aStringToRead will be
  * determined by scanning the buffer for the first null byte.
  */
-extern nsresult NS_NewByteInputStream(
-    nsIInputStream** aStreamResult, mozilla::Span<const char> aStringToRead,
-    nsAssignmentType aAssignment = NS_ASSIGNMENT_DEPEND);
+extern nsresult NS_NewByteInputStream(nsIInputStream** aStreamResult,
+                                      mozilla::Span<const char> aStringToRead,
+                                      nsAssignmentType aAssignment);
 
 /**
  * Factory method to get an nsInputStream from an nsACString.  Result will
  * implement nsIStringInputStream, nsTellableStream and nsISeekableStream.
  */
 extern nsresult NS_NewCStringInputStream(nsIInputStream** aStreamResult,
                                          const nsACString& aStringToRead);
 extern nsresult NS_NewCStringInputStream(nsIInputStream** aStreamResult,
--- a/xpcom/tests/gtest/TestSnappyStreams.cpp
+++ b/xpcom/tests/gtest/TestSnappyStreams.cpp
@@ -80,17 +80,18 @@ static void TestCompressUncompress(uint3
     EXPECT_EQ(inputData[i], outputData.get()[i]) << "Byte " << i;
   }
 }
 
 static void TestUncompressCorrupt(const char* aCorruptData,
                                   uint32_t aCorruptLength) {
   nsCOMPtr<nsIInputStream> source;
   nsresult rv = NS_NewByteInputStream(getter_AddRefs(source),
-                                      MakeSpan(aCorruptData, aCorruptLength));
+                                      MakeSpan(aCorruptData, aCorruptLength),
+                                      NS_ASSIGNMENT_DEPEND);
   ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   nsCOMPtr<nsIInputStream> uncompress = new SnappyUncompressInputStream(source);
 
   nsAutoCString outputData;
   rv = NS_ConsumeStream(uncompress, UINT32_MAX, outputData);
   ASSERT_EQ(NS_ERROR_CORRUPTED_CONTENT, rv);
 }