]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix an off-by-one error in GridIn::read_vtk.
authorMayank Sabharwal <msabharw@ualberta.ca>
Wed, 16 Nov 2016 04:12:16 +0000 (21:12 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 16 Nov 2016 04:17:03 +0000 (21:17 -0700)
source/grid/grid_in.cc

index 9a06ab8156088914693c7030cb709e63345d0c73..25459fc09269d144c4cd711edcc70c4fffa51345 100644 (file)
@@ -224,7 +224,7 @@ void GridIn<dim, spacedim>::read_vtk(std::istream &in)
                     {
                       subcelldata.boundary_quads.back().vertices[j] = vertex_indices[subcelldata.boundary_quads.back().vertices[j]];
                     }
-                  quad_indices[no_quads] = no_quads + 1;
+                  quad_indices[no_quads] = no_quads;
                   no_quads++;
                 }
 
@@ -272,7 +272,7 @@ void GridIn<dim, spacedim>::read_vtk(std::istream &in)
                     {
                       subcelldata.boundary_lines.back().vertices[j] = vertex_indices[subcelldata.boundary_lines.back().vertices[j]];
                     }
-                  line_indices[no_lines] = no_lines + 1;
+                  line_indices[no_lines] = no_lines;
                   no_lines++;
                 }
 
@@ -361,6 +361,7 @@ void GridIn<dim, spacedim>::read_vtk(std::istream &in)
                 {
                   double id;
                   in >> id;
+                  Assert (quad_indices[i] < subcelldata.boundary_quads.size(), ExcInternalError());
                   subcelldata.boundary_quads[quad_indices[i]].material_id = id;
                 }
             }
@@ -370,6 +371,7 @@ void GridIn<dim, spacedim>::read_vtk(std::istream &in)
                 {
                   double id;
                   in >> id;
+                  Assert (line_indices[i] < subcelldata.boundary_lines.size(), ExcInternalError());
                   subcelldata.boundary_lines[line_indices[i]].material_id = id;
                 }
             }

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.