# HG changeset patch # User Jorg K # Date 1507406461 -7200 # Sat Oct 07 22:01:01 2017 +0200 # Node ID 3d4d669c055763b5a4f8973084cc881c88c08beb # Parent 91836f48fb2bf81dd061153971bdd6d25a434a33 Bug 1403771 - don't clone m_inputStream since it will never close. rs=bustage-fix diff --git a/mailnews/base/util/nsMsgProtocol.cpp b/mailnews/base/util/nsMsgProtocol.cpp --- a/mailnews/base/util/nsMsgProtocol.cpp +++ b/mailnews/base/util/nsMsgProtocol.cpp @@ -36,17 +36,16 @@ #include "nsIMsgIncomingServer.h" #include "nsIInputStreamPump.h" #include "nsICancelable.h" #include "nsMimeTypes.h" #include "mozilla/Services.h" #include #include "nsContentSecurityManager.h" #include "SlicedInputStream.h" -#include "nsStreamUtils.h" #undef PostMessage // avoid to collision with WinUser.h using namespace mozilla; NS_IMPL_ISUPPORTS(nsMsgProtocol, nsIChannel, nsIStreamListener, nsIRequestObserver, nsIRequest, nsITransportEventSink) @@ -470,33 +469,23 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * if (NS_FAILED(rv)) return rv; } int64_t offset = 0; nsCOMPtr seekable(do_QueryInterface(m_inputStream)); if (seekable && NS_FAILED(seekable->Tell(&offset))) { offset = 0; } - nsCOMPtr clonedStream; - nsCOMPtr replacementStream; - rv = NS_CloneInputStream(m_inputStream, - getter_AddRefs(clonedStream), - getter_AddRefs(replacementStream)); - NS_ENSURE_SUCCESS(rv, rv); - if (replacementStream) { - // If m_inputStream is not cloneable, NS_CloneInputStream will clone - // it using a pipe. In order to keep the copy alive and working, we - // have to replace the original stream with the replacement. - m_inputStream = replacementStream.forget(); - } // m_readCount can be -1 which means "read as much as we can". // We pass this on as UINT64_MAX, which is in fact uint64_t(-1). + // We don't clone m_inputStream here, we simply give up ownership + // since otherwise the original would never be closed. RefPtr slicedStream = - new SlicedInputStream(clonedStream.forget(), uint64_t(offset), + new SlicedInputStream(m_inputStream.forget(), uint64_t(offset), m_readCount == -1 ? UINT64_MAX : uint64_t(m_readCount)); nsCOMPtr pump; rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream); if (NS_FAILED(rv)) return rv; m_request = pump; // keep a reference to the pump so we can cancel it // put us in a state where we are always notified of incoming data