[Spice-devel] [PATCH v2 18/24] Catch all std::exception derivatives (including std::bad_alloc, not a std::bad_alloc)

Christophe de Dinechin christophe at dinechin.org
Wed Feb 21 17:46:30 UTC 2018


From: Christophe de Dinechin <dinechin at redhat.com>

I also added a catch-all clause for double plus extra safety

Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
---
 src/spice-streaming-agent.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index f9d8855..26fa910 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -623,10 +623,14 @@ int main(int argc, char* argv[])
         FrameLog frame_log(log_filename, log_binary);
         agent.CaptureLoop(streamfd, frame_log);
     }
-    catch (std::runtime_error &err) {
+    catch (std::exception &err) {
         syslog(LOG_ERR, "%s\n", err.what());
         ret = EXIT_FAILURE;
     }
+    catch (...) {
+        syslog(LOG_ERR, "Unexpected exception caught (probably thronw by plugin init");
+        ret = EXIT_FAILURE;
+    }
 
     closelog();
     return ret;
-- 
2.13.5 (Apple Git-94)



More information about the Spice-devel mailing list