From 9e7b4b7f89cc1b535480d8bad03b7681ef8c196d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 27 Feb 2024 19:43:21 -0500 Subject: [PATCH] Avoid nullptr dereference when loading group info Fixes https://gitlab.com/kicad/code/kicad/-/issues/17154 --- pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp index 1e94648a3a..2aa1461be4 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp @@ -1257,14 +1257,14 @@ void PCB_IO_KICAD_SEXPR_PARSER::resolveGroups( BOARD_ITEM* aParent ) { for( const KIID& aUuid : groupInfo->memberUuids ) { - BOARD_ITEM* item; + BOARD_ITEM* item = nullptr; if( m_appendToExisting ) item = getItem( m_resetKIIDMap[ aUuid.AsString() ] ); else item = getItem( aUuid ); - if( item->Type() == NOT_USED ) + if( !item || item->Type() == NOT_USED ) { // This is the deleted item singleton, which means we didn't find the uuid. continue;