Bug 581628. We can end up in situations where mConnection is null due to our use of async proxies that eat error codes. r=sdwilsh, a=bzbarsky
authorDaniel Richard G. <skunk@iSKUNK.ORG>
Fri, 19 Nov 2010 09:18:08 -0500
changeset 57898 ee499eb8ad11dd8fa15ac434a055421cabe9bd91
parent 57897 2e2e864a29593436480c97199a4e762c69d87f55
child 57899 e211245e413a99bbe511514af3f3dd6919344ed5
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerssdwilsh, bzbarsky
bugs581628
milestone2.0b8pre
Bug 581628. We can end up in situations where mConnection is null due to our use of async proxies that eat error codes. r=sdwilsh, a=bzbarsky
toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp
--- a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp
@@ -3179,22 +3179,24 @@ nsUrlClassifierDBServiceWorker::SetupUpd
   return NS_OK;
 }
 
 nsresult
 nsUrlClassifierDBServiceWorker::ApplyUpdate()
 {
   LOG(("nsUrlClassifierDBServiceWorker::ApplyUpdate"));
 
-  if (NS_FAILED(mUpdateStatus)) {
-    mConnection->RollbackTransaction();
-  } else {
-    mUpdateStatus = FlushChunkLists();
-    if (NS_SUCCEEDED(mUpdateStatus)) {
-      mUpdateStatus = mConnection->CommitTransaction();
+  if (mConnection) {
+    if (NS_FAILED(mUpdateStatus)) {
+      mConnection->RollbackTransaction();
+    } else {
+      mUpdateStatus = FlushChunkLists();
+      if (NS_SUCCEEDED(mUpdateStatus)) {
+        mUpdateStatus = mConnection->CommitTransaction();
+      }
     }
   }
 
   if (NS_SUCCEEDED(mUpdateStatus)) {
     // We have modified the db, we can't trust the set of clean
     // fragments or domains anymore.
     ResetLookupCache();
   }
@@ -3221,17 +3223,18 @@ nsUrlClassifierDBServiceWorker::FinishUp
     return NS_ERROR_NOT_INITIALIZED;
 
   NS_ENSURE_STATE(!mInStream);
   NS_ENSURE_STATE(mUpdateObserver);
 
   // We need to get the error code before ApplyUpdate, because it might
   // close/open the connection.
   PRInt32 errcode = SQLITE_OK;
-  mConnection->GetLastError(&errcode);
+  if (mConnection)
+    mConnection->GetLastError(&errcode);
 
   ApplyUpdate();
 
   if (NS_SUCCEEDED(mUpdateStatus)) {
     mUpdateObserver->UpdateSuccess(mUpdateWait);
   } else {
     mUpdateObserver->UpdateError(mUpdateStatus);
   }