Prevent segfault when aOutline has no vertices.

When attempting to read a pcad file exported from Altium, kicad was
segfaulting because it was trying to access an empty array. This patch
fixes that.

The reason the array was empty was the the board outline in the pcad
file was composed of only arcs and the plugin only processes lines in
the board outline. Adding this functionality is for another patch I
suppose.

Signed-off-by: Clemens Koller <cko@embeon.de>
This commit is contained in:
hauptmech 2017-02-13 22:07:56 +01:00 committed by Chris Pavlina
parent 175d68fbb1
commit 461c72c034
1 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -94,8 +94,11 @@ void PCB_POLYGON::SetOutline( VERTICES_ARRAY* aOutline )
for( i = 0; i < (int) aOutline->GetCount(); i++ ) for( i = 0; i < (int) aOutline->GetCount(); i++ )
m_outline.Add( new wxRealPoint( (*aOutline)[i]->x, (*aOutline)[i]->y ) ); m_outline.Add( new wxRealPoint( (*aOutline)[i]->x, (*aOutline)[i]->y ) );
m_positionX = m_outline[0]->x; if( m_outline.Count() > 0 )
m_positionY = m_outline[0]->y; {
m_positionX = m_outline[0]->x;
m_positionY = m_outline[0]->y;
}
} }
void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon, void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,