Merge pull request #3532 from maxGimeno/Surface_mesh-Fix_IO-GF

Surface_mesh: Fix segfault in read_off()
This commit is contained in:
Laurent Rineau 2018-12-19 16:06:54 +01:00
commit b45284184c
1 changed files with 15 additions and 3 deletions

View File

@ -2155,10 +2155,18 @@ private: //------------------------------------------------------- private data
std::string off;
is >> sm_skip_comments;
is >> off;
CGAL_assertion( (off == "OFF") || (off == "COFF") || (off == "NOFF") || (off == "CNOFF"));
if(! (
(off == "OFF") || (off == "COFF") || (off == "NOFF") || (off == "CNOFF")
)
)
{
is.setstate(std::ios::failbit);
return false;
}
is >> n >> f >> e;
if(!is){
return false;
}
sm.reserve(sm.num_vertices()+n, sm.num_faces()+2*f, sm.num_edges()+e);
std::vector<Vertex_index> vertexmap(n);
P p;
@ -2215,6 +2223,10 @@ private: //------------------------------------------------------- private data
for(int i=0; i < f; i++){
is >> sm_skip_comments;
is >> d;
if(!is){
sm.clear();
return false;
}
vr.resize(d);
for(std::size_t j=0; j<d; j++){
is >> vi;