From 6f6505f6a13cbc162f66397474b3e0df1afbbc1c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 14 Mar 2022 09:36:10 +0100 Subject: [PATCH] Fix crash in SCH_LABEL_BASE::IsType() when the item is not living in a schematic. It happens for instance when copying the item from the clipboard. From master branch. Fixes #11128 --- eeschema/sch_text.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index bcb59c4411..6b6b09a0ad 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -861,6 +861,11 @@ bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const wxCHECK_MSG( Schematic(), false, wxT( "No parent SCHEMATIC set for SCH_LABEL!" ) ); + // Ensure m_connected_items for Schematic()->CurrentSheet() exists. + // Can be not the case when "this" is living in clipboard + if( m_connected_items.find( Schematic()->CurrentSheet() ) == m_connected_items.end() ) + return false; + const SCH_ITEM_SET& item_set = m_connected_items.at( Schematic()->CurrentSheet() ); for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )