From 359d66bc81cca324329e62145adecde9cf20130a Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 16 Jun 2022 08:20:47 -0700 Subject: [PATCH] Protect against invalid pads Before dereferencing the front of the sequence, we have to ensure that the pad exists on any layer. If not, just return the default (probably F_Cu) for the element --- pcbnew/pad.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 655ebca699..49829b5053 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -209,10 +209,11 @@ PCB_LAYER_ID PAD::GetLayer() const PCB_LAYER_ID PAD::GetPrincipalLayer() const { - if( m_attribute == PAD_ATTRIB::SMD || m_attribute == PAD_ATTRIB::CONN ) + if( m_attribute == PAD_ATTRIB::SMD || m_attribute == PAD_ATTRIB::CONN || GetLayerSet().none() ) return m_layer; else return GetLayerSet().Seq().front(); + }