Bug 1476674 - Fix crash in nsNavHistory::RecalculateOriginFrecencyStats r=mak
authorDrew Willcoxon <adw@mozilla.com>
Thu, 19 Jul 2018 17:15:02 +0000
changeset 482424 522e7b9b689999e87a0fe9921ca66932de6292e7
parent 482423 92bd3b2178623a036ea91990aa5570e039890ff4
child 482425 4b7f106772af7618598c0c417d977f2ea407d767
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1476674
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1476674 - Fix crash in nsNavHistory::RecalculateOriginFrecencyStats r=mak Differential Revision: https://phabricator.services.mozilla.com/D2232
toolkit/components/places/Database.cpp
toolkit/components/places/nsNavHistory.cpp
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -2723,17 +2723,19 @@ Database::MigrateV52OriginFrecencies()
     // The migration has already been completed.
     return;
   }
 
   RefPtr<MigrateV52OriginFrecenciesRunnable> runnable(
     new MigrateV52OriginFrecenciesRunnable(mMainConn));
   nsCOMPtr<nsIEventTarget> target(do_GetInterface(mMainConn));
   MOZ_ASSERT(target);
-  Unused << target->Dispatch(runnable, NS_DISPATCH_NORMAL);
+  if (target) {
+    Unused << target->Dispatch(runnable, NS_DISPATCH_NORMAL);
+  }
 }
 
 nsresult
 Database::MigrateV52Up()
 {
   // Before this migration, moz_origin.frecency is the max frecency of all
   // places with the origin.  After this migration, it's the sum of frecencies
   // of all places with the origin.
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -709,19 +709,18 @@ nsNavHistory::RecalculateOriginFrecencyS
   nsMainThreadPtrHandle<nsIObserver> callback(
     !aCallback ? nullptr :
     new nsMainThreadPtrHolder<nsIObserver>(
       "nsNavHistory::RecalculateOriginFrecencyStats callback",
       aCallback
     )
   );
 
-  nsCOMPtr<mozIStorageConnection> conn = mDB->MainConn();
-  nsCOMPtr<nsIEventTarget> target = do_GetInterface(conn);
-  MOZ_ASSERT(target);
+  nsCOMPtr<nsIEventTarget> target(do_GetInterface(mDB->MainConn()));
+  NS_ENSURE_STATE(target);
   nsresult rv = target->Dispatch(NS_NewRunnableFunction(
     "nsNavHistory::RecalculateOriginFrecencyStats",
     [self, callback] {
       Unused << self->RecalculateOriginFrecencyStatsInternal();
       Unused << NS_DispatchToMainThread(NS_NewRunnableFunction(
         "nsNavHistory::RecalculateOriginFrecencyStats callback",
         [callback] {
           if (callback) {