Bug 1509685 - Add more bounds checking in nsMsgDBView::UpdateDisplayMessage() to avoid crashes, take 2. r=alta88
authorJorg K <jorgk@jorgk.com>
Wed, 28 Nov 2018 21:48:00 +0100
changeset 33802 8249b1aa65abd9dfe2ff696df2074d5919a069d5
parent 33801 42d96198196c4a9f672bb65feaf0d499e75abd2e
child 33803 8aa4e74965cab0cbf395f3dd6921c84233eea906
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersalta88
bugs1509685
Bug 1509685 - Add more bounds checking in nsMsgDBView::UpdateDisplayMessage() to avoid crashes, take 2. r=alta88
mailnews/base/src/nsMsgDBView.cpp
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -1210,16 +1210,18 @@ nsMsgDBView::LoadMessageByViewIndex(nsMs
   nsCString uri;
   nsresult rv = GetURIForViewIndex(aViewIndex, uri);
   if (!mSuppressMsgDisplay && !m_currentlyDisplayedMsgUri.Equals(uri))
   {
     NS_ENSURE_SUCCESS(rv,rv);
     nsCOMPtr<nsIMessenger> messenger (do_QueryReferent(mMessengerWeak));
     NS_ENSURE_TRUE(messenger, NS_ERROR_FAILURE);
     messenger->OpenURL(uri);
+    if (aViewIndex >= (nsMsgViewIndex)m_keys.Length())
+      return NS_MSG_INVALID_DBVIEW_INDEX;
     m_currentlyDisplayedMsgKey = m_keys[aViewIndex];
     m_currentlyDisplayedMsgUri = uri;
     m_currentlyDisplayedViewIndex = aViewIndex;
     UpdateDisplayMessage(m_currentlyDisplayedViewIndex);
   }
 
   return NS_OK;
 }