aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-01-06 12:00:30 -0500
committerJack Lloyd <[email protected]>2017-01-06 12:00:30 -0500
commit13c7c64da3c474504f2e92850111bceefd169029 (patch)
tree36ed8deadb6d6e7c31d8d4488be737fb65a4afab /src
parent8a9583a14724ea6a25100532d1e46c1721a4680c (diff)
Add try/catch blocks in noexcept destructors that might throw
Flagged by Coverity
Diffstat (limited to 'src')
-rw-r--r--src/lib/prov/pkcs11/p11_module.cpp9
-rw-r--r--src/lib/prov/pkcs11/p11_object.cpp11
-rw-r--r--src/lib/prov/pkcs11/p11_session.cpp17
3 files changed, 29 insertions, 8 deletions
diff --git a/src/lib/prov/pkcs11/p11_module.cpp b/src/lib/prov/pkcs11/p11_module.cpp
index 4ea3dc56d..ba8b659b9 100644
--- a/src/lib/prov/pkcs11/p11_module.cpp
+++ b/src/lib/prov/pkcs11/p11_module.cpp
@@ -20,7 +20,14 @@ Module::Module(const std::string& file_path, C_InitializeArgs init_args)
Module::~Module() BOTAN_NOEXCEPT
{
- m_low_level->C_Finalize(nullptr, nullptr);
+ try
+ {
+ m_low_level->C_Finalize(nullptr, nullptr);
+ }
+ catch(...)
+ {
+ // we are noexcept and must swallow any exception here
+ }
}
void Module::reload(C_InitializeArgs init_args)
diff --git a/src/lib/prov/pkcs11/p11_object.cpp b/src/lib/prov/pkcs11/p11_object.cpp
index 872fdf8b7..5f078fd31 100644
--- a/src/lib/prov/pkcs11/p11_object.cpp
+++ b/src/lib/prov/pkcs11/p11_object.cpp
@@ -92,9 +92,16 @@ ObjectFinder::ObjectFinder(Session& session, const std::vector<Attribute>& searc
ObjectFinder::~ObjectFinder() BOTAN_NOEXCEPT
{
- if(m_search_terminated == false)
+ try
{
- module()->C_FindObjectsFinal(m_session.get().handle(), nullptr);
+ if(m_search_terminated == false)
+ {
+ module()->C_FindObjectsFinal(m_session.get().handle(), nullptr);
+ }
+ }
+ catch(...)
+ {
+ // ignore error during noexcept function
}
}
diff --git a/src/lib/prov/pkcs11/p11_session.cpp b/src/lib/prov/pkcs11/p11_session.cpp
index ceb316169..71397eea5 100644
--- a/src/lib/prov/pkcs11/p11_session.cpp
+++ b/src/lib/prov/pkcs11/p11_session.cpp
@@ -38,14 +38,21 @@ Session::Session(Slot& slot, SessionHandle handle)
Session::~Session() BOTAN_NOEXCEPT
{
- if(m_handle)
+ try
{
- if(m_logged_in)
+ if(m_handle)
{
- module()->C_Logout(m_handle, nullptr);
+ if(m_logged_in)
+ {
+ module()->C_Logout(m_handle, nullptr);
+ }
+ module()->C_CloseSession(m_handle, nullptr);
+ m_handle = 0;
}
- module()->C_CloseSession(m_handle, nullptr);
- m_handle = 0;
+ }
+ catch(...)
+ {
+ // exception during noexcept destructor is ignored
}
}