From b6734006391fbd757220e17cade7a7afd33ac6bc Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Thu, 28 Jul 2022 08:50:59 -0500 Subject: Issue #1312 - Fix potential crashes in MailNews. These are straightforward, one-line changes with no obvious dependencies. Probably could have been taken a long time ago. Ref: BZ 1638634, 1606091 --- mailnews/base/src/nsMessenger.cpp | 14 +++++++------- mailnews/imap/src/nsImapMailFolder.cpp | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'mailnews') diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 953b462b6a..c9de533ae7 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -233,6 +233,13 @@ NS_IMETHODIMP nsMessenger::SetWindow(mozIDOMWindowProxy *aWin, nsIMsgWindow *aMs do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); + // Remove the folder listener if we added it, i.e. if mWindow is non-null + if (mWindow) + { + rv = mailSession->RemoveFolderListener(this); + NS_ENSURE_SUCCESS(rv, rv); + } + if (aWin) { mMsgWindow = aMsgWindow; @@ -271,13 +278,6 @@ NS_IMETHODIMP nsMessenger::SetWindow(mozIDOMWindowProxy *aWin, nsIMsgWindow *aMs } // if aWin else { - // Remove the folder listener if we added it, i.e. if mWindow is non-null - if (mWindow) - { - rv = mailSession->RemoveFolderListener(this); - NS_ENSURE_SUCCESS(rv, rv); - } - mWindow = nullptr; } diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index da1411cd08..1d08472bb9 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -1803,6 +1803,7 @@ nsImapMailFolder::GetImapIncomingServer(nsIImapIncomingServer **aImapIncomingSer if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server) { nsCOMPtr incomingServer = do_QueryInterface(server); + NS_ENSURE_TRUE(incomingServer, NS_ERROR_NO_INTERFACE); incomingServer.swap(*aImapIncomingServer); return NS_OK; } -- cgit v1.2.3