SHAPE_POLY_SET: fix segfault when checking for a point in empty polyset

This commit is contained in:
unknown 2015-09-02 08:32:24 +02:00 committed by jean-pierre charras
parent 1d877f5b74
commit 276a923027
1 changed files with 6 additions and 0 deletions

View File

@ -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;
}