Bug 1336005 - Add null check when releasing and shutting down background thread draft
authorThomas Nguyen <tnguyen@mozilla.com>
Tue, 07 Feb 2017 10:06:21 +0800
changeset 479654 349ff3ae0ee2d96e6c832aceddd599781452b0db
parent 479651 af8a2573d0f1e9cc6f2ba0ab67d7a702a197f177
child 544743 daa58abc9861efe884800a1e59465986ae3eacf8
push id44317
push usertnguyen@mozilla.com
push dateTue, 07 Feb 2017 02:06:51 +0000
bugs1336005
milestone54.0a1
Bug 1336005 - Add null check when releasing and shutting down background thread 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;
   }