From 2fc07561f1a7ca35dbb9a73a01e1d41ef51b9252 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 21 Dec 2017 09:49:55 +0100 Subject: [PATCH] Fix crash when drawing a polygon with empty outline In theory there should be no polygons with empty outline, but as you see there was at least one leading to a crash. Fixes: lp:1739455 * https://bugs.launchpad.net/kicad/+bug/1739455 --- common/gal/opengl/opengl_gal.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 616580ddce..66b696fd89 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -822,6 +822,10 @@ void OPENGL_GAL::DrawPolygon( const SHAPE_POLY_SET& aPolySet ) for( int j = 0; j < aPolySet.OutlineCount(); ++j ) { const SHAPE_LINE_CHAIN& outline = aPolySet.COutline( j ); + + if( outline.SegmentCount() == 0 ) + continue; + const int pointCount = outline.SegmentCount() + 1; std::unique_ptr points( new GLdouble[3 * pointCount] ); GLdouble* ptr = points.get();