mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibJS: Explictly assert that a null GCPtr is not dereferenced
This commit is contained in:
parent
8379b87d4e
commit
0ec433edce
Notes:
sideshowbarker
2024-07-17 03:18:59 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0ec433edce Pull-request: https://github.com/SerenityOS/serenity/pull/16480
@ -52,6 +52,7 @@ public:
|
||||
NonnullGCPtr& operator=(GCPtr<T> const& other)
|
||||
{
|
||||
m_ptr = const_cast<T*>(other.ptr());
|
||||
VERIFY(m_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -186,8 +187,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
T* operator->() const { return m_ptr; }
|
||||
T& operator*() const { return *m_ptr; }
|
||||
T* operator->() const
|
||||
{
|
||||
VERIFY(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T& operator*() const
|
||||
{
|
||||
VERIFY(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
T* ptr() const { return m_ptr; }
|
||||
|
||||
operator bool() const { return !!m_ptr; }
|
||||
|
Loading…
Reference in New Issue
Block a user