From edd7f5e229b55cc660d7e6594288bd0be8283f47 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 30 Oct 2024 17:46:10 +0100 Subject: [PATCH] BOARD_COMMIT::Revert(): protect against null pointer. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19011 --- pcbnew/board_commit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 4afec3111d..3726cdede4 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -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( parent )->Add( boardItem, ADD_MODE::INSERT ); }