Bug 1185223 - crash at [@ mozilla::dom::quota::QuotaObject::Release() ]; r=khuey, a=sylvestre
authorJan Varga <jan.varga@gmail.com>
Sat, 10 Oct 2015 09:28:09 +0200
changeset 289575 1153ec762010
parent 289574 ed67ac61d1c0
child 289576 2d497358081c
push id5196
push usercbook@mozilla.com
push date2015-10-19 07:20 +0000
treeherdermozilla-beta@135164c79784 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sylvestre
bugs1185223
milestone42.0
Bug 1185223 - crash at [@ mozilla::dom::quota::QuotaObject::Release() ]; r=khuey, a=sylvestre
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -16377,31 +16377,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;
   }