diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index d221528d29..c6434df55b 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -570,6 +570,11 @@ bool SHAPE_LINE_CHAIN::Parse( std::stringstream& aStream ) m_points.clear(); aStream >> n_pts; + + // Rough sanity check, just make sure the loop bounds aren't absolutely outlandish + if( n_pts < 0 || n_pts > aStream.str().size() ) + return false; + aStream >> m_closed; for( int i = 0; i < n_pts; i++ ) @@ -581,4 +586,4 @@ bool SHAPE_LINE_CHAIN::Parse( std::stringstream& aStream ) } return true; -} \ No newline at end of file +}