Bug 1275518 - Add null pointer check before accessing DatabaseInfo::mConnection. r=janv, a=gchang
authorBevis Tseng <btseng@mozilla.com>
Wed, 17 Aug 2016 16:13:50 +0800
changeset 340447 901d8d3d4597f8a437aaacc9d6bd999ef24fd6b9
parent 340446 4169e451cbd0677090bdd648f010434b27599c94
child 340448 2b7afd7a12b637f6db6acdd78b627a6f7c60389c
push id6337
push userryanvm@gmail.com
push dateThu, 25 Aug 2016 03:33:50 +0000
treeherdermozilla-beta@901d8d3d4597 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, gchang
bugs1275518
milestone49.0
Bug 1275518 - Add null pointer check before accessing DatabaseInfo::mConnection. r=janv, a=gchang
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -12512,22 +12512,26 @@ IdleConnectionRunnable::Run()
   MOZ_ASSERT(mDatabaseInfo);
   MOZ_ASSERT(!mDatabaseInfo->mIdle);
 
   nsCOMPtr<nsIEventTarget> owningThread;
   mOwningThread.swap(owningThread);
 
   if (owningThread) {
     mDatabaseInfo->AssertIsOnConnectionThread();
-    MOZ_ASSERT(mDatabaseInfo->mConnection);
-    mDatabaseInfo->mConnection->DoIdleProcessing(mNeedsCheckpoint);
-
-    MOZ_ALWAYS_SUCCEEDS(
-      owningThread->Dispatch(this, NS_DISPATCH_NORMAL));
-    return NS_OK;
+
+    // The connection could be null if EnsureConnection() didn't run or was not
+    // successful in TransactionDatabaseOperationBase::RunOnConnectionThread().
+    if (mDatabaseInfo->mConnection) {
+      mDatabaseInfo->mConnection->DoIdleProcessing(mNeedsCheckpoint);
+
+      MOZ_ALWAYS_SUCCEEDS(
+        owningThread->Dispatch(this, NS_DISPATCH_NORMAL));
+      return NS_OK;
+    }
   }
 
   RefPtr<ConnectionPool> connectionPool = mDatabaseInfo->mConnectionPool;
   MOZ_ASSERT(connectionPool);
 
   if (mDatabaseInfo->mClosing || mDatabaseInfo->TotalTransactionCount()) {
     MOZ_ASSERT(!connectionPool->
                  mDatabasesPerformingIdleMaintenance.Contains(mDatabaseInfo));
@@ -12556,16 +12560,18 @@ CloseConnectionRunnable::Run()
                  js::ProfileEntry::Category::STORAGE);
 
   if (mOwningThread) {
     MOZ_ASSERT(mDatabaseInfo->mClosing);
 
     nsCOMPtr<nsIEventTarget> owningThread;
     mOwningThread.swap(owningThread);
 
+    // The connection could be null if EnsureConnection() didn't run or was not
+    // successful in TransactionDatabaseOperationBase::RunOnConnectionThread().
     if (mDatabaseInfo->mConnection) {
       mDatabaseInfo->AssertIsOnConnectionThread();
 
       mDatabaseInfo->mConnection->Close();
 
       IDB_DEBUG_LOG(("ConnectionPool closed connection 0x%p",
                      mDatabaseInfo->mConnection.get()));