From 6029fae30bd9c55cbbae9b28f13e720e70800816 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 21 Feb 2023 07:14:03 -0500 Subject: [PATCH] Catch parsing exceptions of the local repository.json Fixes KICAD-B9 --- kicad/pcm/pcm.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kicad/pcm/pcm.cpp b/kicad/pcm/pcm.cpp index 4201a5c035..c11b63a28e 100644 --- a/kicad/pcm/pcm.cpp +++ b/kicad/pcm/pcm.cpp @@ -451,9 +451,18 @@ const bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryI if( repo_cache.FileExists() && packages_cache.FileExists() ) { - std::ifstream repo_stream( repo_cache.GetFullPath().ToUTF8() ); - repo_stream >> js; - PCM_REPOSITORY saved_repo = js.get(); + std::ifstream repo_stream( repo_cache.GetFullPath().ToUTF8() ); + PCM_REPOSITORY saved_repo; + try + { + repo_stream >> js; + saved_repo = js.get(); + } + catch( ... ) + { + if( m_dialog ) + wxLogError( _( "Failed to parse locally stored repository.json." ) ); + } if( saved_repo.packages.update_timestamp == current_repo.packages.update_timestamp ) {