]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a problem where we were running past the end of an array and still
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 18 May 2004 21:47:40 +0000 (21:47 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 18 May 2004 21:47:40 +0000 (21:47 +0000)
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

index 26370850e93bf0ea03d505abcca44b122ad1558b..ec70e24e9e02d0cfc56a74614fc8206ba4963ad4 100644 (file)
@@ -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;
-    };
+    }
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.