From 3e8acdcb8c28e9691f83fb24ea4fefff1f8984af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 7 Apr 2013 19:11:22 +0000 Subject: [PATCH] Added bounds checking via BOOST_ASSERT to operator[] [SVN r83797] --- include/boost/container/stable_vector.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 2de4ae1..3da8c64 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -1127,7 +1127,10 @@ class stable_vector //! //! Complexity: Constant. reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //! @@ -1138,7 +1141,10 @@ class stable_vector //! //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[n]).value; } + { + BOOST_ASSERT(n < this->size()); + return static_cast(*this->index[n]).value; + } //! Requires: size() > n. //!