From 78734f6ad332a6ae99feed669d1bdc98bc91a13a Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 22 Aug 2014 10:49:22 +0200 Subject: [PATCH] Add assertions for out-of-bounds indices. --- src/vector.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vector.hpp b/src/vector.hpp index 5b8305a..3cf4863 100644 --- a/src/vector.hpp +++ b/src/vector.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #if !defined(NDEBUG) #include @@ -65,8 +66,8 @@ namespace cloonel { template const Vector& operator*= ( U parOther ); template const Vector& operator/= ( U parOther ); - T& operator[] ( uint32_t parIndex ) { return m_mem[parIndex]; } - const T& operator[] ( uint32_t parIndex ) const { return m_mem[parIndex]; } + T& operator[] ( uint32_t parIndex ) { assert(parIndex < S); return m_mem[parIndex]; } + const T& operator[] ( uint32_t parIndex ) const { assert(parIndex < S); return m_mem[parIndex]; } private: T m_mem[S];