From bc57b8147f138c1d067f4ff8d38a2ed50c4bb679 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Tue, 1 Nov 2005 09:01:20 +0000 Subject: [PATCH] FIX avoid past end derefence in insert THANKS Jan Amtrup [SVN r31523] --- include/boost/numeric/ublas/storage_sparse.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/ublas/storage_sparse.hpp b/include/boost/numeric/ublas/storage_sparse.hpp index f4867f48..9fbb3d8f 100644 --- a/include/boost/numeric/ublas/storage_sparse.hpp +++ b/include/boost/numeric/ublas/storage_sparse.hpp @@ -378,7 +378,7 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::pair insert (const value_type &p) { iterator it = detail::lower_bound (begin (), end (), p, detail::less_pair ()); - if (it->first == p.first) + if (it != end () && it->first == p.first) return std::make_pair (it, false); difference_type n = it - begin (); BOOST_UBLAS_CHECK (size () == 0 || size () == size_type (n), external_logic ());