From 548f86b98bba4cd53c8607f55fad6dc3cf6f955f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Dec 2018 14:35:25 +0100 Subject: [PATCH 1/2] Check stream state before allocating memory. --- Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index ce5490de872..b5099136f3e 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -2098,7 +2098,9 @@ private: //------------------------------------------------------- private data CGAL_assertion( (off == "OFF") || (off == "COFF") || (off == "NOFF") || (off == "CNOFF")); 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 vertexmap(n); P p; @@ -2151,6 +2153,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> vi; From b04369cc6b78c5f1ccf42b9e36a57f0065931b35 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Dec 2018 14:55:00 +0100 Subject: [PATCH 2/2] Don't assert OFF type --- Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index b5099136f3e..947c0c8aeae 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -2095,8 +2095,14 @@ 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;