Eeschema: fix segfault bug when LIB_PART has no aliases.
The GetName() method attempts to access the first LIB_ALIAS pointer in the m_aliases member without checking if m_aliases is empty. This should never happen because a new LIB_PART creates a LIB_ALIAS object in the ctor. Some how, this is getting bypassed and causing Eeschema to crash in the LIB_PART dtor on debug builds. GetName() now checks for an empty alias list to prevent a null pointer segfault. Fixes lp:1739614 https://bugs.launchpad.net/kicad/+bug/1739614
This commit is contained in:
parent
70f516bde4
commit
51717aad22
|
@ -265,6 +265,16 @@ wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
|
|||
}
|
||||
|
||||
|
||||
const wxString& LIB_PART::GetName() const
|
||||
{
|
||||
static wxString dummy;
|
||||
|
||||
wxCHECK_MSG( m_aliases.size(), dummy, "no aliases defined for symbol" );
|
||||
|
||||
return m_aliases[0]->GetName();
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::SetName( const wxString& aName )
|
||||
{
|
||||
m_libId.SetLibItemName( aName, false );
|
||||
|
|
|
@ -262,7 +262,7 @@ public:
|
|||
|
||||
virtual void SetName( const wxString& aName );
|
||||
|
||||
const wxString& GetName() const { return m_aliases[0]->GetName(); }
|
||||
const wxString& GetName() const;
|
||||
|
||||
const LIB_ID& GetLibId() const { return m_libId; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue