From 7dd9304d24bcd5822f3aec0acb8b9c4d8edabde1 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 30 Sep 2019 04:52:59 -0700 Subject: [PATCH] Fix null-dereference in libedit Clearing the CurPart sets to null. Need to keep datasheet checks behind guards --- eeschema/libedit/lib_edit_frame.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index c8923f7c64..448164ea8d 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -381,8 +381,12 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) delete m_my_part; m_my_part = aPart; - // Datasheet field is special; copy it to the root alias docfilename - m_my_part->GetField( DATASHEET )->SetText( aPart->GetRootAlias()->GetDocFileName() ); + // Datasheet field is special; copy it to the root alias docfilename but watch out + // for clearing the aPart + if( m_my_part ) + { + m_my_part->GetField( DATASHEET )->SetText( aPart->GetRootAlias()->GetDocFileName() ); + } } // select the current component in the tree widget