Title: [197270] releases/WebKitGTK/webkit-2.4/Source/WebCore
Revision
197270
Author
[email protected]
Date
2016-02-28 02:37:01 -0800 (Sun, 28 Feb 2016)

Log Message

Merge r183398 - Crashes under IDBDatabase::closeConnection
https://bugs.webkit.org/show_bug.cgi?id=141745

Reviewed by Alexey Proskuryakov.

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::~IDBDatabase): Do the work of close/closeConnection without
actually calling those functions.
(WebCore::IDBDatabase::closeConnection): Protect the database so it's not destroyed
in the middle of this function's execution.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (197269 => 197270)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2016-02-28 10:35:02 UTC (rev 197269)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2016-02-28 10:37:01 UTC (rev 197270)
@@ -1,3 +1,16 @@
+2015-04-27  Darin Adler  <[email protected]>
+
+        Crashes under IDBDatabase::closeConnection
+        https://bugs.webkit.org/show_bug.cgi?id=141745
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::~IDBDatabase): Do the work of close/closeConnection without
+        actually calling those functions.
+        (WebCore::IDBDatabase::closeConnection): Protect the database so it's not destroyed
+        in the middle of this function's execution.
+
 2015-02-23  Brent Fulgham  <[email protected]>
 
         EventHandler references deleted Scrollbar

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (197269 => 197270)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2016-02-28 10:35:02 UTC (rev 197269)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2016-02-28 10:37:01 UTC (rev 197270)
@@ -72,7 +72,26 @@
 
 IDBDatabase::~IDBDatabase()
 {
-    close();
+    // This does what IDBDatabase::close does, but without any ref/deref of the
+    // database since it is already in the process of being deleted. The logic here
+    // is also simpler since we know there are no transactions (since they ref the
+    // database when they are alive).
+
+    ASSERT(m_transactions.isEmpty());
+
+    if (!m_closePending) {
+        m_closePending = true;
+        m_backend->close(m_databaseCallbacks);
+    }
+
+    if (auto* context = scriptExecutionContext()) {
+        // Remove any pending versionchange events scheduled to fire on this
+        // connection. They would have been scheduled by the backend when another
+        // connection called setVersion, but the frontend connection is being
+        // closed before they could fire.
+        for (auto& event : m_enqueuedEvents)
+            context->eventQueue().cancelEvent(*event);
+    }
 }
 
 int64_t IDBDatabase::nextTransactionId()
@@ -286,6 +305,10 @@
     ASSERT(m_closePending);
     ASSERT(m_transactions.isEmpty());
 
+    // Closing may result in deallocating the last transaction, which could result in deleting
+    // this IDBDatabase. We need the deallocation to happen after we are through.
+    Ref<IDBDatabase> protect(*this);
+
     m_backend->close(m_databaseCallbacks);
 
     if (m_contextStopped || !scriptExecutionContext())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to