Bug 1462316 - fix crash in nsAbView::OnItemAdded(). r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Sat, 06 Oct 2018 21:06:14 +0200
changeset 32199 4a0cc2432f6f801b08bc3a5b240723a335a97b98
parent 32198 332f8acdf8e61f57557f121e545efa783a12d142
child 32200 a9ffca9797d521606c4dbc6f4ca71ac9353abb76
push id2322
push usermozilla@jorgk.com
push dateMon, 15 Oct 2018 18:43:25 +0000
treeherdercomm-beta@e9f0f4d5d705 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1462316
Bug 1462316 - fix crash in nsAbView::OnItemAdded(). r=mkmelin a=jorgk
mailnews/addrbook/src/nsAbView.cpp
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -833,16 +833,19 @@ nsCString getQuery(nsCOMPtr<nsIAbDirecto
   if (searchBegin == kNotFound)
     return EmptyCString();
 
   return nsCString(Substring(uri, searchBegin));
 }
 
 NS_IMETHODIMP nsAbView::OnItemAdded(nsISupports *parentDir, nsISupports *item)
 {
+  if (!mDirectory)  // No address book selected.
+    return NS_OK;
+
   nsresult rv;
   nsCOMPtr <nsIAbDirectory> directory = do_QueryInterface(parentDir, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   bool isRemote = isDirectoryRemote(directory);
   // If the search is performed on All Address books, its possible that the LDAP
   // results start coming when mDirectory has changed (LDAP search works in an
   // asynchronous manner).