← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Prevent segfault when aOutline has no vertices.

 

Hi hauptmech,

I've been informed that my terseness could be mistaken for lack of
appreciation for your efforts.  I apologize if the that was your
impression because that was not my intent.  I am extremely busy at the
moment so I am trying to keep my responses as short as possible and the
amount of work I need to do to commit patches to a minimum.  Thank you
for your contribution to KiCad.

Cheers,

Wayne

On 2/13/2017 8:32 AM, Wayne Stambaugh wrote:
> Please fix you coding policy violations so this patch can be merged.
> 
> On 2/13/2017 6:30 AM, hauptmech wrote:
>> 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.
>>
>> -hauptmech
>>
>> ---
>>  pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
>> b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
>> index 6d7045fb9..664742056 100644
>> --- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
>> +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp
>> @@ -94,8 +94,10 @@ void PCB_POLYGON::SetOutline( VERTICES_ARRAY* aOutline )
>>      for( i = 0; i < (int) aOutline->GetCount(); i++ )
>>          m_outline.Add( new wxRealPoint( (*aOutline)[i]->x,
>> (*aOutline)[i]->y ) );
>>
>> -    m_positionX = m_outline[0]->x;
>> -    m_positionY = m_outline[0]->y;
>> +   if (m_outline.Count() > 0){
>> +       m_positionX = m_outline[0]->x;
>> +       m_positionY = m_outline[0]->y;
>> +   }
>>  }
>>
>>  void PCB_POLYGON::FormPolygon( XNODE*   aNode, VERTICES_ARRAY* aPolygon,


References