From 5b632376dc58b58dcfd8c73ece4b6ea698a8f61f Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Sat, 6 Jun 2015 16:55:01 +0200 Subject: [PATCH] fix: add catch-all block around main in signer This fixes the problem that destructors aren't called during stack-unwinding, if the exception in question is never caught, which might in the worst-case prevent the wiping of private keys. --- src/apps/signer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apps/signer.cpp b/src/apps/signer.cpp index 0d027c0..baa45c7 100644 --- a/src/apps/signer.cpp +++ b/src/apps/signer.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "db/database.h" #include "db/mysql.h" @@ -21,7 +22,7 @@ extern std::string serialPath; -int main( int argc, const char* argv[] ) { +int main( int argc, const char* argv[] ) try { ( void ) argc; ( void ) argv; @@ -63,4 +64,11 @@ int main( int argc, const char* argv[] ) { } return -1; + +} catch(std::exception& e) { + std::cerr << "Fatal Error: " << e.what() << "!\n"; + return -1; +} catch(...) { + std::cerr << "Fatal Error: Unknown Exception!\n"; + return -1; } -- 2.39.2