From 7ba02bad7c773e95c49b60ec8be4302f5039501a Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 24 Aug 2015 13:30:26 -0400 Subject: [PATCH] Pcbnew: bug fix and minor changes in github plugin. (fixes lp:1484331) * Catch all unhandled exceptions derived from std::exception() class in KICAD_PLUGIN::get_remote_zip() to prevent KiCad from crashing when exceptions are thrown from the C++ standard library. * Make boost::system::system_error() catch const and and improve comments about avhttp library usage in KICAD_PLUGIN::get_remote_zip(). Thanks to Dick Hollenbeck for these improvements. --- pcbnew/github/github_plugin.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index c3c6b91d7a..8d1da4fc1b 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -495,17 +495,21 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL ) zip_url += "/zip/master"; #endif } + else { // This is the generic code path for any server which can serve - // up zip files which is not github.com. The schemes tested include: - // http and https, I don't know what the avhttp library supports beyond that. + // up zip files. The schemes tested include: http and https. + // (I don't know what the avhttp library supports beyond that.) // zip_url goal: "://[:]/" // Remember that , , if present, and all came // from the lib_path in the fp-lib-table row. + // This code path is used with the nginx proxy setup, but is useful + // beyond that. + zip_url += repo.GetServer(); if( repo.HasPort() ) @@ -561,7 +565,7 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) // 4 lines, using SSL, top that. } - catch( boost::system::system_error& e ) + catch( const boost::system::system_error& e ) { // https "GET" has faild, report this to API caller. static const char errorcmd[] = "http GET command failed"; // Do not translate this message @@ -579,8 +583,16 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) THROW_IO_ERROR( msg ); } + catch( const exception& exc ) + { + UTF8 error( _( "Exception '%s' in avhttp while open()-ing URI:'%s'" ) ); + + string msg = StrPrintf( error.c_str(), exc.what(), zip_url.c_str() ); + THROW_IO_ERROR( msg ); + } } + // This GITHUB_GETLIBLIST method should not be here, but in github_getliblist.cpp ! // However it is here just because we need to include to compile it. // and when we include avhttp in two .cpp files, the link fails because it detects duplicate