From 6b6fa94c913e9cd5f5460328f833f2c6b19541b1 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 29 Jan 2018 13:50:09 +0100 Subject: [PATCH] Catch exceptions to please coverity Actually, the possible exception path is from replaceEnvironmentPath. It would be better if coverity was able to asses that our hardcoded regexp:s are correct. --- src/LyX.cpp | 15 ++++++++++----- src/Server.cpp | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/LyX.cpp b/src/LyX.cpp index 4e97f7ae64..575bd06daa 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -483,12 +483,17 @@ int LyX::init(int & argc, char * argv[]) } // Initialization of LyX (reads lyxrc and more) - LYXERR(Debug::INIT, "Initializing LyX::init..."); - bool success = init(); - LYXERR(Debug::INIT, "Initializing LyX::init...done"); - if (!success) + try { + LYXERR(Debug::INIT, "Initializing LyX::init..."); + bool success = init(); + LYXERR(Debug::INIT, "Initializing LyX::init...done"); + if (!success) + return EXIT_FAILURE; + } catch (exception const &e) { + // This can happen _in_theory_ in replaceEnvironmentPath + lyxerr << "Caught exception `" << e.what() << "'." << endl; return EXIT_FAILURE; - + } // Remaining arguments are assumed to be files to load. for (int argi = 1; argi < argc; ++argi) pimpl_->files_to_load_.push_back(os::utf8_argv(argi)); diff --git a/src/Server.cpp b/src/Server.cpp index 8953c78dc3..64e2af15d3 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -1067,7 +1067,10 @@ Server::~Server() string message; for (int i = 0; i != numclients_; ++i) { message = "LYXSRV:" + clients_[i] + ":bye\n"; - pipes_.send(message); + // ignore exceptions, we are quitting anyway + try { + pipes_.send(message); + } catch (...) {} } } -- 2.39.2