← Back to team overview

kicad-developers team mailing list archive

[PATCH] Uncaught exception in project_rescue.cpp

 

This patch fixes Coverity issue 109780 in project_rescue.cpp - an 
uncaught exception on load or save of the project library list.

--
Chris
commit d06ab0c601e517f493156f88fc2f098980afa028
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date:   Mon Aug 10 02:40:04 2015 -0400

    Fix uncaught exception in project_rescue.cpp:insert_library

diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp
index cc1c281..6d3371d 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.

Follow ups