diff --git a/xs/src/admesh/normals.c b/xs/src/admesh/normals.c index 843a25d16a..b4a0166d0b 100644 --- a/xs/src/admesh/normals.c +++ b/xs/src/admesh/normals.c @@ -142,7 +142,8 @@ stl_fix_normal_directions(stl_file *stl) { } } /* If this edge of the facet is connected: */ - if(stl->neighbors_start[facet_num].neighbor[j] != -1) { + if(stl->neighbors_start[facet_num].neighbor[j] != -1 && + stl->neighbors_start[facet_num].neighbor[j] < stl->stats.number_of_facets*sizeof(char)) { /* If we haven't fixed this facet yet, add it to the list: */ if(norm_sw[stl->neighbors_start[facet_num].neighbor[j]] != 1) { /* Add node to beginning of list. */