Modern IDB: Possible crash deallocating IDBDatabaseInfo/IDBObjectStoreInfo/IDBIndexInfo.
[WebKit-https.git] / Source / WebCore / Modules / indexeddb / shared / IDBDatabaseInfo.cpp
index 7cdb91e..23ce920 100644 (file)
@@ -40,18 +40,18 @@ IDBDatabaseInfo::IDBDatabaseInfo(const String& name, uint64_t version)
 {
 }
 
-IDBDatabaseInfo IDBDatabaseInfo::isolatedCopy() const
+IDBDatabaseInfo::IDBDatabaseInfo(const IDBDatabaseInfo& other, IsolatedCopyTag)
+    : m_name(other.m_name.isolatedCopy())
+    , m_version(other.m_version)
+    , m_maxObjectStoreID(other.m_maxObjectStoreID)
 {
-    IDBDatabaseInfo info;
-
-    info.m_name = m_name.isolatedCopy();
-    info.m_version = m_version;
-    info.m_maxObjectStoreID = m_maxObjectStoreID;
-
-    for (auto entry : m_objectStoreMap)
-        info.m_objectStoreMap.set(entry.key, entry.value.isolatedCopy());
+    for (auto entry : other.m_objectStoreMap)
+        m_objectStoreMap.set(entry.key, entry.value.isolatedCopy());
+}
 
-    return info;
+IDBDatabaseInfo IDBDatabaseInfo::isolatedCopy() const
+{
+    return { *this, IDBDatabaseInfo::IsolatedCopy };
 }
 
 bool IDBDatabaseInfo::hasObjectStore(const String& name) const