From 051e6b3de2f863835404d8fb81ba91de23d497de Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 18 May 2004 21:47:40 +0000 Subject: [PATCH] Fix a problem where we were running past the end of an array and still dereferenced the iterator. git-svn-id: https://svn.dealii.org/trunk@9260 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/dofs/dof_constraints.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 26370850e9..ec70e24e9e 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -1176,7 +1176,17 @@ bool ConstraintMatrix::is_identity_constrained (const unsigned int index) const p = std::lower_bound (lines.begin (), lines.end (), index_comparison); - return ((p->line == index) && + // return if an entry for this + // line was found and if it has + // only one entry equal to 1.0 + // + // note that lower_bound only + // returns a valid iterator if + // 'index' is less than the + // largest line index in out + // constraints list + return ((p != lines.end()) && + (p->line == index) && (p->entries.size() == 1) && (p->entries[0].second == 1.0)); } @@ -1189,7 +1199,7 @@ bool ConstraintMatrix::is_identity_constrained (const unsigned int index) const (i->entries[0].second == 1.0)); return false; - }; + } } -- 2.39.5