From 00fb54214619e62bb076d17150d89d05c3193ed6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 20 Oct 2023 16:02:03 +0100 Subject: [PATCH] nullptr safety Fixes https://gitlab.com/kicad/code/kicad/-/issues/15906 --- pcbnew/generators/pcb_tuning_pattern.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pcbnew/generators/pcb_tuning_pattern.cpp b/pcbnew/generators/pcb_tuning_pattern.cpp index fdffca8c11..0fa4646bf9 100644 --- a/pcbnew/generators/pcb_tuning_pattern.cpp +++ b/pcbnew/generators/pcb_tuning_pattern.cpp @@ -1753,16 +1753,19 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) m_tuningPattern = PCB_TUNING_PATTERN::CreateNew( generatorTool, m_frame, m_pickerItem, mode ); - int dummyDist; - int dummyClearance = std::numeric_limits::max() / 2; - VECTOR2I closestPt; + if( m_tuningPattern ) + { + int dummyDist; + int dummyClearance = std::numeric_limits::max() / 2; + VECTOR2I closestPt; - m_pickerItem->GetEffectiveShape()->Collide( cursorPos, dummyClearance, - &dummyDist, &closestPt ); - m_tuningPattern->SetPosition( closestPt ); - m_tuningPattern->SetEnd( closestPt ); + m_pickerItem->GetEffectiveShape()->Collide( cursorPos, dummyClearance, + &dummyDist, &closestPt ); + m_tuningPattern->SetPosition( closestPt ); + m_tuningPattern->SetEnd( closestPt ); - m_preview.Add( m_tuningPattern ); + m_preview.Add( m_tuningPattern ); + } } else if( m_pickerItem && m_tuningPattern ) {