Bug 1336005 - Add null check when releasing and shutting down background thread r=francois
authorThomas Nguyen <tnguyen@mozilla.com>
Tue, 07 Feb 2017 10:06:21 +0800
changeset 479890 ce39540ba30ffe06bd6042d990f5aa806f4dfc86
parent 479889 3a6b42b3d2335f99d68d1e63ac6bb04a8ec78b4c
child 479891 2ff48b77d380c9c649d2f5f1d54b4f5c5b3340ad
push id44393
push userVYV03354@nifty.ne.jp
push dateTue, 07 Feb 2017 13:53:48 +0000
reviewersfrancois
bugs1336005
milestone54.0a1
Bug 1336005 - Add null check when releasing and shutting down background thread r=francois MozReview-Commit-ID: HKlQLqQH2c9
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1887,16 +1887,21 @@ nsUrlClassifierDBService::Observe(nsISup
   } else if (!strcmp(aTopic, "quit-application")) {
     Shutdown();
   } else if (!strcmp(aTopic, "profile-before-change")) {
     // Unit test does not receive "quit-application",
     // need call shutdown in this case
     Shutdown();
     LOG(("joining background thread"));
     mWorkerProxy = nullptr;
+
+    if (!gDbBackgroundThread) {
+      return NS_OK;
+    }
+
     nsIThread *backgroundThread = gDbBackgroundThread;
     gDbBackgroundThread = nullptr;
     backgroundThread->Shutdown();
     NS_RELEASE(backgroundThread);
   } else {
     return NS_ERROR_UNEXPECTED;
   }