[Chromium] IndexedDB: Memory leak in IDBCallbacksProxy::onSuccess(PassRefPtr<IDBDatab...
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 22:31:53 +0000 (22:31 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 22:31:53 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104615

Reviewed by Tony Chang.

Don't create (and leak) a new wrapper object for onSuccess if one was created for onUpgradeNeeded.

* src/IDBCallbacksProxy.cpp:
(WebKit::IDBCallbacksProxy::IDBCallbacksProxy):
(WebKit::IDBCallbacksProxy::onSuccess):
(WebKit::IDBCallbacksProxy::onUpgradeNeeded):
* src/IDBCallbacksProxy.h:
(IDBCallbacksProxy):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137773 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/IDBCallbacksProxy.cpp
Source/WebKit/chromium/src/IDBCallbacksProxy.h

index 57c606b..921eba9 100644 (file)
@@ -1,3 +1,19 @@
+2012-12-14  Joshua Bell  <jsbell@chromium.org>
+
+        [Chromium] IndexedDB: Memory leak in IDBCallbacksProxy::onSuccess(PassRefPtr<IDBDatabaseBackendInterface>)
+        https://bugs.webkit.org/show_bug.cgi?id=104615
+
+        Reviewed by Tony Chang.
+
+        Don't create (and leak) a new wrapper object for onSuccess if one was created for onUpgradeNeeded.
+
+        * src/IDBCallbacksProxy.cpp:
+        (WebKit::IDBCallbacksProxy::IDBCallbacksProxy):
+        (WebKit::IDBCallbacksProxy::onSuccess):
+        (WebKit::IDBCallbacksProxy::onUpgradeNeeded):
+        * src/IDBCallbacksProxy.h:
+        (IDBCallbacksProxy):
+
 2012-12-14  Yusuf Ozuysal  <yusufo@google.com>
 
         Send a message from WebViewImpl to the compositor to inform about end of flings
index 837cc32..160184b 100644 (file)
@@ -59,6 +59,7 @@ PassRefPtr<IDBCallbacksProxy> IDBCallbacksProxy::create(PassOwnPtr<WebIDBCallbac
 
 IDBCallbacksProxy::IDBCallbacksProxy(PassOwnPtr<WebIDBCallbacks> callbacks)
     : m_callbacks(callbacks)
+    , m_didCreateProxy(false)
 {
 }
 
@@ -79,7 +80,8 @@ void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBCursorBackendInterface> idbCurso
 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> backend)
 {
     ASSERT(m_databaseCallbacks.get());
-    m_callbacks->onSuccess(new WebIDBDatabaseImpl(backend, m_databaseCallbacks.release()));
+    WebIDBDatabaseImpl* impl = m_didCreateProxy ? 0 : new WebIDBDatabaseImpl(backend, m_databaseCallbacks.release());
+    m_callbacks->onSuccess(impl);
 }
 
 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBKey> idbKey)
@@ -147,6 +149,7 @@ void IDBCallbacksProxy::onBlocked(int64_t existingVersion)
 void IDBCallbacksProxy::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBTransactionBackendInterface> transaction, PassRefPtr<IDBDatabaseBackendInterface> database)
 {
     ASSERT(m_databaseCallbacks);
+    m_didCreateProxy = true;
     m_callbacks->onUpgradeNeeded(oldVersion, new WebIDBTransactionImpl(transaction), new WebIDBDatabaseImpl(database, m_databaseCallbacks));
 }
 
index 65f3b74..e4e8843 100644 (file)
@@ -68,6 +68,7 @@ private:
 
     OwnPtr<WebIDBCallbacks> m_callbacks;
     RefPtr<IDBDatabaseCallbacksProxy> m_databaseCallbacks;
+    bool m_didCreateProxy;
 };
 
 } // namespace WebKit