From c343b36a39358a833228c9530a6344aec12166b6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 28 Apr 2019 14:09:46 -0700 Subject: [PATCH] SHAPE_POLY_SET: avoid invalid polygon Ensures the polygon index is never used unless it exists in the vector --- include/geometry/shape_poly_set.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/geometry/shape_poly_set.h b/include/geometry/shape_poly_set.h index 099aca63a2..d1deeafe75 100644 --- a/include/geometry/shape_poly_set.h +++ b/include/geometry/shape_poly_set.h @@ -165,9 +165,9 @@ class SHAPE_POLY_SET : public SHAPE operator bool() const { - return ( ( m_currentPolygon < m_lastPolygon ) || ( IsLastPolygon() && - ( m_currentContour < static_cast( m_poly->CPolygon( m_currentPolygon ).size() ) || - ( IsEndContour() && m_currentVertex < m_poly->CPolygon( m_currentPolygon )[m_currentContour].PointCount() ) + return ( ( m_currentPolygon < m_lastPolygon ) || ( m_currentPolygon == m_poly->OutlineCount() - 1 && + ( m_currentContour < static_cast( m_poly->CPolygon( m_currentPolygon ).size() ) - 1 || + ( m_currentVertex < m_poly->CPolygon( m_currentPolygon )[m_currentContour].PointCount() ) ) ) ); }