From c964d40dd8352d12f6f9ee0739a56f9dc6ae9470 Mon Sep 17 00:00:00 2001 From: John Hood Date: Wed, 24 Feb 2016 20:29:41 -0500 Subject: [PATCH] Do not throw from destructors, fatal_assert() instead. --- src/crypto/crypto.cc | 5 ++--- src/network/network.cc | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/crypto/crypto.cc b/src/crypto/crypto.cc index c1f002a..f9d0404 100644 --- a/src/crypto/crypto.cc +++ b/src/crypto/crypto.cc @@ -41,6 +41,7 @@ #include "byteorder.h" #include "crypto.h" #include "base64.h" +#include "fatal_assert.h" #include "prng.h" using namespace std; @@ -171,9 +172,7 @@ Session::Session( Base64Key s_key ) Session::~Session() { - if ( ae_clear( ctx ) != AE_SUCCESS ) { - throw CryptoException( "Could not clear AES-OCB context." ); - } + fatal_assert( ae_clear( ctx ) == AE_SUCCESS ); } Nonce::Nonce( uint64_t val ) diff --git a/src/network/network.cc b/src/network/network.cc index 9441131..87d8afd 100644 --- a/src/network/network.cc +++ b/src/network/network.cc @@ -639,9 +639,7 @@ uint64_t Connection::timeout( void ) const Connection::Socket::~Socket() { - if ( close( _fd ) < 0 ) { - throw NetworkException( "close", errno ); - } + fatal_assert ( close( _fd ) == 0 ); } Connection::Socket::Socket( const Socket & other )