Bug 1336005 - Add null check when releasing and shutting down background thread. r=francois, a=gchang
authorThomas Nguyen <tnguyen@mozilla.com>
Tue, 07 Feb 2017 10:06:21 +0800
changeset 378281 e625fef0f4bbd0b8388b5bef32a7f1bb9a0875cc
parent 378280 fb6d519b22986ea8978f4bd74f34fb02220b0b0d
child 378282 056b0e09741cc69064ff4bb15457ce8025a78a8f
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois, gchang
bugs1336005
milestone53.0a2
Bug 1336005 - Add null check when releasing and shutting down background thread. r=francois, a=gchang MozReview-Commit-ID: HKlQLqQH2c9
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1880,16 +1880,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;
   }