diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 242b509a7d..05f9dc2f64 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -1117,6 +1117,8 @@ void CAIRO_GAL_BASE::blitCursor( wxMemoryDC& clientDC ) void CAIRO_GAL_BASE::drawPoly( const std::deque& aPointList ) { + wxCHECK( aPointList.size() > 2, /* void */ ); + // Iterate over the point list and draw the segments std::deque::const_iterator it = aPointList.begin(); @@ -1140,6 +1142,8 @@ void CAIRO_GAL_BASE::drawPoly( const std::deque& aPointList ) void CAIRO_GAL_BASE::drawPoly( const VECTOR2D aPointList[], int aListSize ) { + wxCHECK( aListSize > 2, /* void */ ); + // Iterate over the point list and draw the segments const VECTOR2D* ptr = aPointList; @@ -1162,8 +1166,7 @@ void CAIRO_GAL_BASE::drawPoly( const VECTOR2D aPointList[], int aListSize ) void CAIRO_GAL_BASE::drawPoly( const SHAPE_LINE_CHAIN& aLineChain ) { - if( aLineChain.PointCount() < 2 ) - return; + wxCHECK( aLineChain.PointCount() > 2, /* void */ ); syncLineWidth(); diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index ccd4349727..b2c7f98d9b 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -978,6 +978,7 @@ void OPENGL_GAL::DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) void OPENGL_GAL::DrawPolygon( const std::deque& aPointList ) { + wxCHECK( aPointList.size() > 2, /* void */ ); auto points = std::unique_ptr( new GLdouble[3 * aPointList.size()] ); GLdouble* ptr = points.get(); @@ -994,6 +995,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque& aPointList ) void OPENGL_GAL::DrawPolygon( const VECTOR2D aPointList[], int aListSize ) { + wxCHECK( aListSize > 2, /* void */ ); auto points = std::unique_ptr( new GLdouble[3 * aListSize] ); GLdouble* target = points.get(); const VECTOR2D* src = aPointList; @@ -1092,8 +1094,7 @@ void OPENGL_GAL::DrawPolygon( const SHAPE_POLY_SET& aPolySet ) void OPENGL_GAL::DrawPolygon( const SHAPE_LINE_CHAIN& aPolygon ) { - if( aPolygon.SegmentCount() == 0 ) - return; + wxCHECK( aPolygon.PointCount() > 2, /* void */ ); const int pointCount = aPolygon.SegmentCount() + 1; std::unique_ptr points( new GLdouble[3 * pointCount] );