mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibJS: Explictly assert that a null GCPtr is not dereferenced
This commit is contained in:
parent
8379b87d4e
commit
0ec433edce
1 changed files with 13 additions and 2 deletions
|
@ -52,6 +52,7 @@ public:
|
||||||
NonnullGCPtr& operator=(GCPtr<T> const& other)
|
NonnullGCPtr& operator=(GCPtr<T> const& other)
|
||||||
{
|
{
|
||||||
m_ptr = const_cast<T*>(other.ptr());
|
m_ptr = const_cast<T*>(other.ptr());
|
||||||
|
VERIFY(m_ptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,8 +187,18 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator->() const { return m_ptr; }
|
T* operator->() const
|
||||||
T& operator*() const { return *m_ptr; }
|
{
|
||||||
|
VERIFY(m_ptr);
|
||||||
|
return m_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator*() const
|
||||||
|
{
|
||||||
|
VERIFY(m_ptr);
|
||||||
|
return *m_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
T* ptr() const { return m_ptr; }
|
T* ptr() const { return m_ptr; }
|
||||||
|
|
||||||
operator bool() const { return !!m_ptr; }
|
operator bool() const { return !!m_ptr; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue