Bug 1185223 - crash at [@ mozilla::dom::quota::QuotaObject::Release() ]; r=khuey, a=lizzard
authorJan Varga <jan.varga@gmail.com>
Sat, 10 Oct 2015 09:28:09 +0200
changeset 296491 85ec9994546feac0447d11dd1b7bdb87c4058d72
parent 296490 551a28778624d4aff67b698952b1b3e011fc21f7
child 296492 863e41485ec154cf9d36f3a0539d14ea286ea417
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, lizzard
bugs1185223
milestone43.0a2
Bug 1185223 - crash at [@ mozilla::dom::quota::QuotaObject::Release() ]; r=khuey, a=lizzard
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -17406,31 +17406,52 @@ QuotaClient::PerformIdleMaintenanceOnDat
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(mMaintenanceThreadPool);
   MOZ_ASSERT(mMaintenanceStartTime);
   MOZ_ASSERT(!aMaintenanceInfo.mDatabasePath.IsEmpty());
   MOZ_ASSERT(!aMaintenanceInfo.mGroup.IsEmpty());
   MOZ_ASSERT(!aMaintenanceInfo.mOrigin.IsEmpty());
 
+  class MOZ_STACK_CLASS AutoClose final
+  {
+    nsCOMPtr<mozIStorageConnection> mConnection;
+
+  public:
+    AutoClose(mozIStorageConnection* aConnection)
+      : mConnection(aConnection)
+    {
+      MOZ_ASSERT(aConnection);
+    }
+
+    ~AutoClose()
+    {
+      MOZ_ASSERT(mConnection);
+
+      MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mConnection->Close()));
+    }
+  };
+
   nsCOMPtr<nsIFile> databaseFile =
     GetFileForPath(aMaintenanceInfo.mDatabasePath);
   MOZ_ASSERT(databaseFile);
 
   nsCOMPtr<mozIStorageConnection> connection;
   nsresult rv = GetStorageConnection(databaseFile,
                                      aMaintenanceInfo.mPersistenceType,
                                      aMaintenanceInfo.mGroup,
                                      aMaintenanceInfo.mOrigin,
                                      TelemetryIdForFile(databaseFile),
                                      getter_AddRefs(connection));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
+  AutoClose autoClose(connection);
+
   if (IdleMaintenanceMustEnd(aRunId)) {
     return;
   }
 
   AutoProgressHandler progressHandler(this, aRunId);
   if (NS_WARN_IF(NS_FAILED(progressHandler.Register(connection)))) {
     return;
   }