Bug 1460561 - nsMultiplexInputStream should behave correctly when NS_InputStreamIsBuffered() is used, r=michal

This commit is contained in:
Andrea Marchesini 2018-05-24 07:51:53 +02:00
Родитель 1d3ef19262
Коммит 4d94837722
1 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -27,6 +27,8 @@
#include "mozilla/ipc/InputStreamUtils.h"
#include "nsIAsyncInputStream.h"
#include "nsIInputStreamLength.h"
#include "nsNetUtil.h"
#include "nsStreamUtils.h"
using namespace mozilla;
using namespace mozilla::ipc;
@ -240,6 +242,16 @@ nsMultiplexInputStream::GetCount(uint32_t* aCount)
NS_IMETHODIMP
nsMultiplexInputStream::AppendStream(nsIInputStream* aStream)
{
nsCOMPtr<nsIInputStream> stream = aStream;
if (!NS_InputStreamIsBuffered(stream)) {
nsCOMPtr<nsIInputStream> bufferedStream;
nsresult rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
stream.forget(), 4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = bufferedStream;
}
MutexAutoLock lock(mLock);
StreamData* streamData = mStreams.AppendElement();
@ -247,7 +259,7 @@ nsMultiplexInputStream::AppendStream(nsIInputStream* aStream)
return NS_ERROR_OUT_OF_MEMORY;
}
streamData->Initialize(aStream);
streamData->Initialize(stream);
UpdateQIMap(*streamData, 1);