Bug 1404045 - follow-up: Use SlicedInputStream() where offset/length for NS_NewInputStreamPump() are necessary. rs=bustage-fix
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -51,16 +51,17 @@
#include "nsIWindowMediator.h"
#include "nsIWindowWatcher.h"
#include "nsCOMPtr.h"
#include "nsMimeTypes.h"
#include "nsIInterfaceRequestor.h"
#include "nsXPCOMCIDInternal.h"
#include "nsIXULAppInfo.h"
#include "nsSyncRunnableHelpers.h"
+#include "SlicedInputStream.h"
static mozilla::LazyLogModule IMAP("IMAP");
// netlib required files
#include "nsIStreamListener.h"
#include "nsIMsgIncomingServer.h"
#include "nsIImapIncomingServer.h"
#include "nsIPrefBranch.h"
@@ -9650,19 +9651,20 @@ bool nsImapMockChannel::ReadFromLocalCac
{
// dougt - This may break the ablity to "cancel" a read from offline mail reading.
// fileChannel->SetLoadGroup(m_loadGroup);
RefPtr<nsImapCacheStreamListener> cacheListener = new nsImapCacheStreamListener();
cacheListener->Init(m_channelListener, this);
// create a stream pump that will async read the specified amount of data.
// XXX make offset/size 64-bit ints
+ RefPtr<SlicedInputStream> slicedStream =
+ new SlicedInputStream(fileStream, uint64_t(offset), uint64_t(size));
nsCOMPtr<nsIInputStreamPump> pump;
- rv = NS_NewInputStreamPump(getter_AddRefs(pump), fileStream,
- offset, (int64_t) size);
+ rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream);
if (NS_SUCCEEDED(rv))
rv = pump->AsyncRead(cacheListener, m_channelContext);
if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
{
// if the msg is unread, we should mark it read on the server. This lets
// the code running this url we're loading from the cache, if it cares.
imapUrl->SetMsgLoadingFromCache(true);
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -75,16 +75,17 @@
#include "nsIStreamConverterService.h"
#include "nsIStreamListenerTee.h"
#include "nsISocketTransport.h"
#include "nsIArray.h"
#include "nsArrayUtils.h"
#include "nsICancelable.h"
#include "nsIInputStreamPump.h"
+#include "SlicedInputStream.h"
#include "nsIProxyInfo.h"
#include "nsContentSecurityManager.h"
#include <time.h>
#undef GetPort // XXX Windows!
#undef SetPort // XXX Windows!
#undef PostMessage // avoid to collision with WinUser.h
@@ -734,19 +735,20 @@ bool nsNNTPProtocol::ReadFromLocalCache(
RefPtr<nsNntpCacheStreamListener> cacheListener =
new nsNntpCacheStreamListener();
cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this), mailnewsUrl);
// create a stream pump that will async read the specified amount of data.
// XXX make size 64-bit int
+ RefPtr<SlicedInputStream> slicedStream =
+ new SlicedInputStream(fileStream, uint64_t(offset), uint64_t(size));
nsCOMPtr<nsIInputStreamPump> pump;
- rv = NS_NewInputStreamPump(getter_AddRefs(pump),
- fileStream, offset, (int64_t) size);
+ rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream);
if (NS_SUCCEEDED(rv))
rv = pump->AsyncRead(cacheListener, m_channelContext);
if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
{
mContentType.Truncate();
m_channelListener = nullptr;
NNTP_LOG_NOTE("Loading message from offline storage");