diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-06-19 21:32:12 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-06-20 15:17:25 +0200 |
commit | 6c7075ee60e799db8b8f94a6d0317ad9bcb75b5d (patch) | |
tree | bfbf86f29b855220b8d54cf5b514202641ff0191 | |
parent | 92741976101e8224291cf9af492209ff5412ca7b (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>
-rw-r--r-- | include/o3tl/deleter.hxx | 49 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/undo/undobj.cxx | 4 |
3 files changed, 34 insertions, 24 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 diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 3f3120606776..8470118e6ceb 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -24,6 +24,7 @@ #include <View.hxx> #include <editeng/outlobj.hxx> #include <editeng/unolingu.hxx> +#include <o3tl/deleter.hxx> #include <svx/obj3d.hxx> #include <svx/fmview.hxx> #include <editeng/outliner.hxx> @@ -145,8 +146,8 @@ View::~View() while(PaintWindowCount()) { // remove all registered OutDevs - // coverity[fun_call_w_exception : SUPPRESS] - cid#485150 silence Uncaught exception - DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/); + // cid#1485150 silence Uncaught exception + suppress_fun_call_w_exception(DeleteWindowFromPaintView(GetFirstOutputDevice())); } } diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 5c2405f32966..02d2a5327c38 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -42,6 +42,7 @@ #include <docsh.hxx> #include <view.hxx> #include <frameformats.hxx> +#include <o3tl/deleter.hxx> #include <sal/log.hxx> // This class saves the Pam as integers and can recompose those into a PaM @@ -1208,7 +1209,8 @@ SwUndoSaveSection::~SwUndoSaveSection() { // SaveSection saves the content in the PostIt section. SwNodes& rUNds = m_pMovedStart->GetNode().GetNodes(); - rUNds.Delete( *m_pMovedStart, m_nMoveLen ); + // cid#1486004 Uncaught exception + suppress_fun_call_w_exception(rUNds.Delete(*m_pMovedStart, m_nMoveLen)); m_pMovedStart.reset(); } |