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).
From master branch.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19713
This commit is contained in:
jean-pierre charras
2025-01-26 08:38:53 +01:00
parent f56e45aa49
commit d4f42a7fef
@@ -1366,7 +1366,9 @@ void PCB_IO_KICAD_SEXPR::formatLayers( LSET aLayerMask, int aNestLevel ) const
output += "(layers";
static const LSET cu_all( LSET::AllCuMask( m_board->GetCopperLayerCount() ) );
static const LSET cu_all( LSET::AllCuMask( m_board // Can be null in some cases in fp editor
? m_board->GetCopperLayerCount()
: MAX_CU_LAYERS ) );
static const LSET fr_bk( 2, B_Cu, F_Cu );
static const LSET adhes( 2, B_Adhes, F_Adhes );
static const LSET paste( 2, B_Paste, F_Paste );