Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2202)

Unified Diff: Source/platform/heap/Handle.h

Issue 1146373002: Oilpan: Validate pointers stored in Persistent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/HeapTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Handle.h
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h
index e6fcd539c63c86c117f63cb8c96a6b97c0f61dbe..47b2a6909e55cf9ea05d77d9d0a9bb4e286aff67 100644
--- a/Source/platform/heap/Handle.h
+++ b/Source/platform/heap/Handle.h
@@ -224,39 +224,41 @@ public:
Persistent(T* raw) : m_raw(raw)
{
- ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->findPageFromAddress(m_raw));
+ checkPointer();
recordBacktrace();
}
explicit Persistent(T& raw) : m_raw(&raw)
{
- ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->findPageFromAddress(m_raw));
+ checkPointer();
recordBacktrace();
}
- Persistent(const Persistent& other) : m_raw(other) { recordBacktrace(); }
-
- template<typename U>
- Persistent(const Persistent<U>& other) : m_raw(other) { recordBacktrace(); }
-
- template<typename U>
- Persistent(const Member<U>& other) : m_raw(other) { recordBacktrace(); }
+ Persistent(const Persistent& other) : m_raw(other)
+ {
+ checkPointer();
+ recordBacktrace();
+ }
template<typename U>
- Persistent(const RawPtr<U>& other) : m_raw(other.get()) { recordBacktrace(); }
+ Persistent(const Persistent<U>& other) : m_raw(other)
+ {
+ checkPointer();
+ recordBacktrace();
+ }
template<typename U>
- Persistent& operator=(U* other)
+ Persistent(const Member<U>& other) : m_raw(other)
{
- m_raw = other;
+ checkPointer();
recordBacktrace();
- return *this;
}
- Persistent& operator=(std::nullptr_t)
+ template<typename U>
+ Persistent(const RawPtr<U>& other) : m_raw(other.get())
{
- m_raw = nullptr;
- return *this;
+ checkPointer();
+ recordBacktrace();
}
void clear() { m_raw = nullptr; }
@@ -293,9 +295,25 @@ public:
T* operator->() const { return *this; }
+ template<typename U>
+ Persistent& operator=(U* other)
+ {
+ m_raw = other;
+ checkPointer();
+ recordBacktrace();
+ return *this;
+ }
+
+ Persistent& operator=(std::nullptr_t)
+ {
+ m_raw = nullptr;
+ return *this;
+ }
+
Persistent& operator=(const Persistent& other)
{
m_raw = other;
+ checkPointer();
recordBacktrace();
return *this;
}
@@ -304,6 +322,7 @@ public:
Persistent& operator=(const Persistent<U>& other)
{
m_raw = other;
+ checkPointer();
recordBacktrace();
return *this;
}
@@ -312,6 +331,7 @@ public:
Persistent& operator=(const Member<U>& other)
{
m_raw = other;
+ checkPointer();
recordBacktrace();
return *this;
}
@@ -320,6 +340,7 @@ public:
Persistent& operator=(const RawPtr<U>& other)
{
m_raw = other;
+ checkPointer();
recordBacktrace();
return *this;
}
@@ -327,6 +348,11 @@ public:
T* get() const { return m_raw; }
private:
+ void checkPointer()
+ {
+ ASSERT(!m_raw || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->findPageFromAddress(m_raw));
+ }
+
#if ENABLE(GC_PROFILING)
void recordBacktrace()
{
« no previous file with comments | « no previous file | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/HeapTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698