Bug 1507718 - crash in nsImapProtocol::GetMessageSize(). Make m_hostSessionList an nsCOMPtr. r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 16 Nov 2018 15:41:13 +0200
changeset 33720 92b165df282fd74680d765eb421ae89648c0731f
parent 33719 47991b387f8df32c9cfe4b918c742134e6b2e11c
child 33721 1a1cb39d41c20a8e8a0c5a3dee4c583c7ef35a04
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersjorgk
bugs1507718
Bug 1507718 - crash in nsImapProtocol::GetMessageSize(). Make m_hostSessionList an nsCOMPtr. r=jorgk
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapProtocol.h
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -519,17 +519,17 @@ nsresult nsImapProtocol::Configure(int32
   m_chunkThreshold = ChunkThreshold;
   m_fetchByChunks = FetchByChunks;
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList,
+nsImapProtocol::Initialize(nsIImapHostSessionList *aHostSessionList,
                            nsIImapIncomingServer *aServer)
 {
   NS_ASSERTION(aHostSessionList && aServer,
     "oops...trying to initialize with a null host session list or server!");
   if (!aHostSessionList || !aServer)
     return NS_ERROR_NULL_POINTER;
 
   nsresult rv = m_downloadLineCache->GrowBuffer(kDownLoadCacheSize);
@@ -539,17 +539,17 @@ nsImapProtocol::Initialize(nsIImapHostSe
   if (!m_flagState)
     return NS_ERROR_OUT_OF_MEMORY;
 
   aServer->GetUseIdle(&m_useIdle);
   aServer->GetForceSelect(m_forceSelectValue);
   aServer->GetUseCondStore(&m_useCondStore);
   aServer->GetUseCompressDeflate(&m_useCompressDeflate);
 
-  m_hostSessionList = aHostSessionList; // no ref count...host session list has life time > connection
+  m_hostSessionList = aHostSessionList;
   m_parser.SetHostSessionList(aHostSessionList);
   m_parser.SetFlagState(m_flagState);
 
   // Initialize the empty mime part string on the main thread.
   rv = IMAPGetStringBundle(getter_AddRefs(m_bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = m_bundle->GetStringFromName("imapEmptyMimePart", m_emptyMimePartString);
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -635,17 +635,17 @@ private:
   RefPtr<nsMsgImapHdrXferInfo> m_hdrDownloadCache;
   nsCOMPtr <nsIImapHeaderInfo> m_curHdrInfo;
   // mapping between mailboxes and the corresponding folder flags
   nsDataHashtable<nsCStringHashKey, int32_t> m_standardListMailboxes;
   // mapping between special xlist mailboxes and the corresponding folder flags
   nsDataHashtable<nsCStringHashKey, int32_t> m_specialXListMailboxes;
 
 
-  nsIImapHostSessionList * m_hostSessionList;
+  nsCOMPtr<nsIImapHostSessionList> m_hostSessionList;
 
   bool m_fromHeaderSeen;
 
   nsString mAcceptLanguages;
 
   // progress stuff
   void SetProgressString(uint32_t aStringIndex);