pcbnew: Fix polygon comparison () for end

This is a v5-only fix incorporating 2c5876e and 72da237 into the 5
branch to resolve a crash when parsing invalid polygons.

Fixes #3752 | https://gitlab.com/kicad/code/kicad/issues/3752
This commit is contained in:
Seth Hillbrand 2020-01-09 17:08:25 -08:00
parent 683c01b301
commit 3444409554
1 changed files with 10 additions and 1 deletions

View File

@ -165,7 +165,16 @@ class SHAPE_POLY_SET : public SHAPE
operator bool() const
{
return m_currentPolygon <= m_lastPolygon;
if( m_currentPolygon < m_lastPolygon )
return true;
if( m_currentPolygon != m_poly->OutlineCount() - 1 )
return false;
const auto& currentPolygon = m_poly->CPolygon( m_currentPolygon );
return m_currentContour < (int) currentPolygon.size() - 1
|| m_currentVertex < currentPolygon[m_currentContour].PointCount();
}
/**