Bug 1336005 - Add null check when releasing and shutting down background thread r=francois
MozReview-Commit-ID: HKlQLqQH2c9
--- 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;
}