From 114f5c668505f4b14c9235ad492f406c1a57cfcd Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 19 Nov 2024 01:09:48 -0600 Subject: [PATCH] [ox/std] Add overflow checking to SpanIterator --- deps/ox/src/ox/std/iterator.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deps/ox/src/ox/std/iterator.hpp b/deps/ox/src/ox/std/iterator.hpp index b8310607..0e85b643 100644 --- a/deps/ox/src/ox/std/iterator.hpp +++ b/deps/ox/src/ox/std/iterator.hpp @@ -8,6 +8,7 @@ #pragma once +#include "error.hpp" #include "math.hpp" #if !__has_include() @@ -129,14 +130,17 @@ struct SpanIterator { } constexpr PtrType operator->() const noexcept { + ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow"); return &m_t[m_offset]; } constexpr RefType operator*() const noexcept { + ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow"); return m_t[m_offset]; } constexpr RefType operator[](std::size_t s) const noexcept { + ox::primitiveAssert(__FILE__, __LINE__, s < m_max, "SpanIterator access overflow"); return m_t[s]; }