diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 00:12:53 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 00:12:53 +0000 |
commit | cc2eb2d7186b1bece6f0250c21e78b5c5e71277c (patch) | |
tree | b678c70eda5535531e5b472da6728d563bdc88ab | |
parent | 3a22b17fcb75299b843aaa0ed4a8c768c80ead1a (diff) | |
download | chromium_src-cc2eb2d7186b1bece6f0250c21e78b5c5e71277c.zip chromium_src-cc2eb2d7186b1bece6f0250c21e78b5c5e71277c.tar.gz chromium_src-cc2eb2d7186b1bece6f0250c21e78b5c5e71277c.tar.bz2 |
Save a reference to the origin passed into the StorageAreaImpl for as long
as the StorageAreaImpl exists since it only stores a pointer to it and
thus it'll refer to freed memory if we don't.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/160675
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22562 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/api/src/WebStorageAreaImpl.cpp | 4 | ||||
-rw-r--r-- | webkit/api/src/WebStorageAreaImpl.h | 5 | ||||
-rw-r--r-- | webkit/api/src/WebStorageNamespaceImpl.cpp | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/webkit/api/src/WebStorageAreaImpl.cpp b/webkit/api/src/WebStorageAreaImpl.cpp index 6a5a762..d7115bf 100644 --- a/webkit/api/src/WebStorageAreaImpl.cpp +++ b/webkit/api/src/WebStorageAreaImpl.cpp @@ -34,12 +34,14 @@ #if ENABLE(DOM_STORAGE) #include "ExceptionCode.h" +#include "SecurityOrigin.h" #include "WebString.h" namespace WebKit { -WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea) +WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea, PassRefPtr<WebCore::SecurityOrigin> origin) : m_storageArea(storageArea) + , m_origin(origin) { } diff --git a/webkit/api/src/WebStorageAreaImpl.h b/webkit/api/src/WebStorageAreaImpl.h index 5e5ffc4..d855360 100644 --- a/webkit/api/src/WebStorageAreaImpl.h +++ b/webkit/api/src/WebStorageAreaImpl.h @@ -40,7 +40,7 @@ namespace WebKit { class WebStorageAreaImpl : public WebStorageArea { public: - WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea); + WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea, PassRefPtr<WebCore::SecurityOrigin> origin); virtual ~WebStorageAreaImpl(); virtual void lock(bool& invalidateCache, size_t& bytesLeftInQuota); virtual void unlock(); @@ -53,6 +53,9 @@ namespace WebKit { private: RefPtr<WebCore::StorageArea> m_storageArea; + + // We must store a reference to this because m_storageArea contains a pointer to it. + RefPtr<WebCore::SecurityOrigin> m_origin; }; } // namespace WebKit diff --git a/webkit/api/src/WebStorageNamespaceImpl.cpp b/webkit/api/src/WebStorageNamespaceImpl.cpp index e6fa684..991aa2a 100644 --- a/webkit/api/src/WebStorageNamespaceImpl.cpp +++ b/webkit/api/src/WebStorageNamespaceImpl.cpp @@ -62,7 +62,7 @@ WebStorageNamespaceImpl::~WebStorageNamespaceImpl() WebStorageArea* WebStorageNamespaceImpl::createStorageArea(const WebString& originString) { RefPtr<WebCore::SecurityOrigin> origin = WebCore::SecurityOrigin::createFromString(originString); - return new WebStorageAreaImpl(m_storageNamespace->storageArea(origin.get())); + return new WebStorageAreaImpl(m_storageNamespace->storageArea(origin.get()), origin.release()); } WebStorageNamespace* WebStorageNamespaceImpl::copy() |