From d6ac303a8cae161a79f41679425c059af90a447d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 20 Nov 2018 20:14:00 +0000 Subject: [PATCH] Don't dereference NULL when checking current part. --- eeschema/libedit/libedit.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index ca7b0a4081..7756a36069 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -575,20 +575,24 @@ void LIB_EDIT_FRAME::OnRevert( wxCommandEvent& aEvent ) if( !ConfirmRevertDialog( this, msg ) ) return; - bool reload_currentPart; + bool reload_currentPart = false; wxString curr_partName = partName; - // the library itself is reverted: the current part will be reloaded only if it is owned by this library - if( partName.IsEmpty() ) + if( GetCurPart() ) { - LIB_ID curr_libId = GetCurPart()->GetLibId(); - reload_currentPart = libName == curr_libId.GetLibNickname(); + // the library itself is reverted: the current part will be reloaded only if it is + // owned by this library + if( partName.IsEmpty() ) + { + LIB_ID curr_libId = GetCurPart()->GetLibId(); + reload_currentPart = libName == curr_libId.GetLibNickname(); - if( reload_currentPart ) - curr_partName = curr_libId.GetLibItemName(); + if( reload_currentPart ) + curr_partName = curr_libId.GetLibItemName(); + } + else + reload_currentPart = isCurrentPart( libId ); } - else - reload_currentPart = isCurrentPart( libId ); int unit = m_unit;