7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 22:13:44 +00:00

BOARD_COMMIT::Revert(): protect against null pointer.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19011
This commit is contained in:
jean-pierre charras 2024-10-30 17:46:10 +01:00
parent 925b219c6a
commit edd7f5e229

View File

@ -682,9 +682,11 @@ void BOARD_COMMIT::Revert()
view->Add( boardItem );
connectivity->Add( boardItem );
// Note: parent can be nullptr, because ent.m_parent is not
// initialized for every ent.m_item, only for some.
BOARD_ITEM* parent = board->GetItem( ent.m_parent );
if( parent->Type() == PCB_FOOTPRINT_T )
if( parent && parent->Type() == PCB_FOOTPRINT_T )
{
static_cast<FOOTPRINT*>( parent )->Add( boardItem, ADD_MODE::INSERT );
}