From 818c1df5ef6ecd9648189cc5ff7b2c3d8d26ad9b Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 10 Nov 2019 19:17:09 -0500 Subject: Bug 646901 - add error checking to fix crash in nsMsgXFVirtualFolderDBView::OnSearchHit(). dbToUse was null Rag #1273 --- mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'mailnews/base/src') diff --git a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp index cdc4f0b5a..61dbca56e 100644 --- a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp +++ b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp @@ -251,10 +251,6 @@ nsMsgXFVirtualFolderDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *aFol NS_ENSURE_ARG(aMsgHdr); NS_ENSURE_ARG(aFolder); - nsCOMPtr dbToUse; - nsCOMPtr folderInfo; - aFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(dbToUse)); - if (m_curFolderGettingHits != aFolder && m_doingSearch && !m_doingQuickSearch) { m_curFolderHasCachedHits = false; @@ -267,11 +263,16 @@ nsMsgXFVirtualFolderDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *aFol m_curFolderStartKeyIndex = m_keys.Length(); } bool hdrInCache = false; - nsCString searchUri; if (!m_doingQuickSearch) { - m_viewFolder->GetURI(searchUri); - dbToUse->HdrIsInCache(searchUri.get(), aMsgHdr, &hdrInCache); + nsCOMPtr dbToUse; + nsCOMPtr dummyInfo; + nsresult rv = aFolder->GetDBFolderInfoAndDB(getter_AddRefs(dummyInfo), getter_AddRefs(dbToUse)); + if (NS_SUCCEEDED(rv)) { + nsCString searchUri; + m_viewFolder->GetURI(searchUri); + dbToUse->HdrIsInCache(searchUri.get(), aMsgHdr, &hdrInCache); + } } if (!m_doingSearch || !m_curFolderHasCachedHits || !hdrInCache) { -- cgit v1.2.3