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
This commit is contained in:
Maciej Suminski 2017-12-21 09:49:55 +01:00
parent 5c6c60def4
commit 2fc07561f1
1 changed files with 4 additions and 0 deletions

View File

@ -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<GLdouble[]> points( new GLdouble[3 * pointCount] );
GLdouble* ptr = points.get();