Bug 1592880 - always return a value in the first parameter of nsMsgDBView::SaveAndClearSelection(). r=alta88 DONTBUILD
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Fri, 01 Nov 2019 10:58:00 +0100
changeset 36542 faa5b18414e564b5df3751aad1f53e5be9e2ab83
parent 36541 9592b5801f6ee0657b37b25ded785694b160c810
child 36543 87b33ca47a7dd6e8df045468593ee1a5678b2404
push id2534
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:52:51 +0000
treeherdercomm-beta@055c50840778 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalta88
bugs1592880
Bug 1592880 - always return a value in the first parameter of nsMsgDBView::SaveAndClearSelection(). r=alta88 DONTBUILD Found with valgrind: Callers may access uninitialized variable.
mailnews/base/src/nsMsgDBView.cpp
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -830,16 +830,20 @@ bool nsMsgDBView::IsOutgoingMsg(nsIMsgDB
   return mEmails.Contains(emailAddress);
 }
 
 // If you call SaveAndClearSelection make sure to call RestoreSelection(),
 // otherwise m_saveRestoreSelectionDepth will be incorrect and will lead to
 // selection msg problems.
 nsresult nsMsgDBView::SaveAndClearSelection(nsMsgKey *aCurrentMsgKey,
                                             nsTArray<nsMsgKey> &aMsgKeyArray) {
+
+  // Always return a value in the first parameter.
+  if (aCurrentMsgKey) *aCurrentMsgKey = nsMsgKey_None;
+
   // We don't do anything on nested Save / Restore calls.
   m_saveRestoreSelectionDepth++;
   if (m_saveRestoreSelectionDepth != 1) return NS_OK;
 
   if (!mTreeSelection || !mTree) return NS_OK;
 
   // First, freeze selection.
   mTreeSelection->SetSelectEventsSuppressed(true);