Bug 1462316 - fix crash in nsAbView::OnItemAdded(). r=mkmelin
authorJorg K <jorgk@jorgk.com>
Sat, 06 Oct 2018 21:06:14 +0200
changeset 33320 8ea70a1b44eae6e9a7d83dd5c79cdca38aa60a9b
parent 33319 b9dada9b780c3c2c1106ef13e06ec74ff5b736e6
child 33321 cd7b757fff58ee7e59982c990223d0dda379a7e2
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin
bugs1462316
Bug 1462316 - fix crash in nsAbView::OnItemAdded(). r=mkmelin
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).