From be38fa5cac5137d3e555853843cfbc705e41a520 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 22 Jan 2025 17:24:18 +0100 Subject: [PATCH] Pcbnew: footprint editor: fix crash when saving a footprint in lib The crash was due to a footprint member (m_board) that is null in some cases in footprint editor (renaming, saving, duplicate a Fp). Fixes https://gitlab.com/kicad/code/kicad/-/issues/19713 --- pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp index 33d48f82c1..5a2d15ba6c 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -1365,7 +1365,9 @@ void PCB_IO_KICAD_SEXPR::format( const FOOTPRINT* aFootprint ) const void PCB_IO_KICAD_SEXPR::formatLayers( LSET aLayerMask ) const { - static const LSET cu_all( LSET::AllCuMask( m_board->GetCopperLayerCount() ) ); + static const LSET cu_all( LSET::AllCuMask( m_board + ? m_board->GetCopperLayerCount() + : MAX_CU_LAYERS ) ); static const LSET fr_bk( { B_Cu, F_Cu } ); static const LSET adhes( { B_Adhes, F_Adhes } ); static const LSET paste( { B_Paste, F_Paste } );