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 31840 1c36ca9a71d4f53e1928d7491f14760e90c37535
parent 31839 1c469b4cdb95110e661179d70486f91cab28fa06
child 31841 6e5794497bbb1d61772a15439b697e3f1b0c59fc
push id85
push usermozilla@jorgk.com
push dateSun, 07 Oct 2018 09:37:17 +0000
treeherdercomm-esr60@147e5e18d4ca [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
@@ -834,16 +834,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).