From 7b034be393a843bfad2733deaf80a68c7383f42e Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 8 Jul 2019 23:13:30 -0500 Subject: [PATCH] [ox/ptrarith] Add asserts to Ptr::operator T* --- deps/ox/src/ox/ptrarith/ptr.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deps/ox/src/ox/ptrarith/ptr.hpp b/deps/ox/src/ox/ptrarith/ptr.hpp index 6c9154e2..81ad934b 100644 --- a/deps/ox/src/ox/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/ptrarith/ptr.hpp @@ -147,11 +147,15 @@ inline T *Ptr::operator->() { template inline Ptr::operator const T*() const { + oxAssert(m_validated, "Unvalidated pointer access. (ox::fs::Ptr::operator const T*())"); + oxAssert(valid(), "Invalid pointer access. (ox::fs::Ptr::operator const T*())"); return reinterpret_cast(m_dataStart + m_itemOffset); } template inline Ptr::operator T*() { + oxAssert(m_validated, "Unvalidated pointer access. (ox::fs::Ptr::operator T*())"); + oxAssert(valid(), "Invalid pointer access. (ox::fs::Ptr::operator T*())"); return reinterpret_cast(m_dataStart + m_itemOffset); }