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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Honza Bambas 2019-04-03 11:39:41 +00:00
parent 1b37794a98
commit 1296f23329
7 changed files with 15 additions and 10 deletions

View File

@ -1536,7 +1536,8 @@ nsresult XMLHttpRequestMainThread::StreamReaderFunc(
// 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");

View File

@ -157,7 +157,8 @@ nsresult nsDeflateConverter::PushAvailableData(nsIRequest *aRequest,
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);

View File

@ -117,8 +117,8 @@ nsresult nsZipDataStream::ProcessData(nsIRequest *aRequest,
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);

View File

@ -378,7 +378,8 @@ nsresult nsHttpTransaction::Init(
// 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;

View File

@ -361,7 +361,8 @@ nsresult StreamFilterParent::Write(Data& aData) {
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 =

View File

@ -47,9 +47,9 @@
* 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

View File

@ -85,7 +85,8 @@ 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);