From d02ca968d1cf435e6e6e751d932ca676d3f2d95b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 18 Sep 2023 09:12:12 +0200 Subject: [PATCH] Eeschema: fix crash if using ${FOOTPRINT_NAME} or ${FOOTPRINT_LIBRARY} as values in fields, if no footprint defined for the symbol. Fixes #15676 https://gitlab.com/kicad/code/kicad/-/issues/15676 --- eeschema/sch_symbol.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 339e458ad9..f99f835606 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1282,7 +1282,11 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i wxArrayString parts = wxSplit( footprint, ':' ); - *token = parts[ 0 ]; + if( parts.Count() > 0 ) + *token = parts[ 0 ]; + else + *token = wxEmptyString; + return true; } else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) ) @@ -1291,7 +1295,11 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i wxArrayString parts = wxSplit( footprint, ':' ); - *token = parts[ std::min( 1, (int) parts.size() - 1 ) ]; + if( parts.Count() > 1 ) + *token = parts[ std::min( 1, (int) parts.size() - 1 ) ]; + else + *token = wxEmptyString; + return true; } else if( token->IsSameAs( wxT( "UNIT" ) ) )