From 140d17bf824e232c9f2a1e219dae91386d916335 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Aug 2015 09:39:13 +0200 Subject: [PATCH] fixes Coverity issue 109780 in project_rescue.cpp: an uncaught exception on load or save of the project library list --- eeschema/project_rescue.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index cc1c2810b3..6d3371d8b4 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -101,15 +101,23 @@ static bool insert_library( PROJECT *aProject, PART_LIB *aLibrary, size_t aIndex aProject->SetElem( PROJECT::ELEM_SCH_PART_LIBS, libs ); } - PART_LIBS::LibNamesAndPaths( aProject, false, &libPaths, &libNames ); + try + { + PART_LIBS::LibNamesAndPaths( aProject, false, &libPaths, &libNames ); - // Make sure the library is not already in the list - while( libNames.Index( libName ) != wxNOT_FOUND ) - libNames.Remove( libName ); + // Make sure the library is not already in the list + while( libNames.Index( libName ) != wxNOT_FOUND ) + libNames.Remove( libName ); - // Add the library to the list and save - libNames.Insert( libName, aIndex ); - PART_LIBS::LibNamesAndPaths( aProject, true, &libPaths, &libNames ); + // Add the library to the list and save + libNames.Insert( libName, aIndex ); + PART_LIBS::LibNamesAndPaths( aProject, true, &libPaths, &libNames ); + } + catch( const IO_ERROR& e ) + { + // Could not get or save the current libraries. + return false; + } // Save the old libraries in case there is a problem after clear(). We'll // put them back in.