From 276a923027e6e701884bce817eee663a00aabae6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Sep 2015 08:32:24 +0200 Subject: [PATCH] SHAPE_POLY_SET: fix segfault when checking for a point in empty polyset --- common/geometry/shape_poly_set.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp index 4c84630ba2..ce289264c2 100644 --- a/common/geometry/shape_poly_set.cpp +++ b/common/geometry/shape_poly_set.cpp @@ -693,11 +693,17 @@ bool SHAPE_POLY_SET::Contains( const VECTOR2I& aP, int aSubpolyIndex ) const { // fixme: support holes! + if( m_polys.size() == 0 ) // empty set? + return false; + if( aSubpolyIndex >= 0 ) return pointInPolygon( aP, m_polys[aSubpolyIndex][0] ); BOOST_FOREACH ( const POLYGON& polys, m_polys ) { + if( polys.size() == 0 ) + continue; + if( pointInPolygon( aP, polys[0] ) ) return true; }