summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-19 21:32:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-20 15:17:25 +0200
commit6c7075ee60e799db8b8f94a6d0317ad9bcb75b5d (patch)
treebfbf86f29b855220b8d54cf5b514202641ff0191 /include/o3tl
parent92741976101e8224291cf9af492209ff5412ca7b (diff)
cid#1485150 suppress Uncaught exception
Change-Id: Ic1b2a44afd15e0720edd48f3502dd2799795551a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117508 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/deleter.hxx49
1 files changed, 28 insertions, 21 deletions
diff --git a/include/o3tl/deleter.hxx b/include/o3tl/deleter.hxx
index 7cb9145eb2a1..ed8b1a583094 100644
--- a/include/o3tl/deleter.hxx
+++ b/include/o3tl/deleter.hxx
@@ -17,6 +17,33 @@
#include <com/sun/star/uno/Exception.hpp>
#include <sal/log.hxx>
+#if defined(__COVERITY__)
+#define suppress_fun_call_w_exception(expr) \
+ do \
+ { \
+ try \
+ { \
+ expr; \
+ } \
+ catch (const css::uno::Exception& ex) \
+ { \
+ SAL_WARN("vcl.app", "Fatal exception: " << exceptionToString(ex)); \
+ std::terminate(); \
+ } \
+ catch (const std::exception& e) \
+ { \
+ SAL_WARN("vcl.app", "Fatal exception: " << e.what()); \
+ std::terminate(); \
+ } \
+ } while (false)
+#else
+#define suppress_fun_call_w_exception(expr) \
+ do \
+ { \
+ expr; \
+ } while (false)
+#endif
+
namespace o3tl
{
/** To markup std::unique_ptr that coverity warns might throw exceptions
@@ -25,27 +52,7 @@ namespace o3tl
*/
template <typename T> struct default_delete
{
- void operator()(T* p) noexcept
- {
-#if defined(__COVERITY__)
- try
- {
- delete p;
- }
- catch (const css::uno::Exception& ex)
- {
- SAL_WARN("vcl.app", "Fatal exception: " << exceptionToString(ex));
- std::terminate();
- }
- catch (const std::exception& e)
- {
- SAL_WARN("vcl.app", "Fatal exception: " << e.what());
- std::terminate();
- }
-#else
- delete p;
-#endif
- }
+ void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); }
};
struct free_delete