From 97dea6ede51deb9ee818fa00a0f32defd76a12c3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 7 May 2020 09:55:13 +0200 Subject: [PATCH] Gerbview: Fix a crash Don't try to close an empty polygon on G37 command. Can happens with malformed Gerber files. From Master, commit 528ebf8. --- gerbview/rs274d.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 7c7629ec5e..210c562408 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -554,7 +554,10 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command ) if( m_Exposure && GetItemsList() ) // End of polygon { GERBER_DRAW_ITEM * gbritem = m_Drawings.GetLast(); - gbritem->m_Polygon.Append( gbritem->m_Polygon.Vertex( 0 ) ); + + if( gbritem->m_Polygon.VertexCount() ) + gbritem->m_Polygon.Append( gbritem->m_Polygon.Vertex( 0 ) ); + StepAndRepeatItem( *gbritem ); } m_Exposure = false;