summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 06:23:08 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 06:23:08 +0000
commit5684fc932039a4d5c54464e56f4f8a045fe76024 (patch)
tree2113b1eb159af69ad78687d2eb4ebc25146d7d3b
parent228316fb7a0e78156ba768429e2568e328b6de4a (diff)
downloadchromium_src-5684fc932039a4d5c54464e56f4f8a045fe76024.zip
chromium_src-5684fc932039a4d5c54464e56f4f8a045fe76024.tar.gz
chromium_src-5684fc932039a4d5c54464e56f4f8a045fe76024.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. Trying to commit this again because I can't repro the errors. TEST=none BUG=none Original CL: http://codereview.chromium.org/160675 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=22562 Review URL: http://codereview.chromium.org/164037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22723 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/api/src/WebStorageAreaImpl.cpp4
-rw-r--r--webkit/api/src/WebStorageAreaImpl.h5
-rw-r--r--webkit/api/src/WebStorageNamespaceImpl.cpp2
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()