diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index d849326119f4..2c813d64c013 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include using namespace ::com::sun::star::container; @@ -435,7 +436,7 @@ std::shared_ptr SvtFilePicker::implCreateDialog( weld::Windo { PickerFlags nBits = getPickerFlags(); - auto dialog = std::make_shared(pParent, nBits); + auto dialog = o3tl::make_shared(pParent, nBits); // Set StandardDir if present if ( !m_aStandardDir.isEmpty()) diff --git a/fpicker/source/office/OfficeFolderPicker.cxx b/fpicker/source/office/OfficeFolderPicker.cxx index 424bf708cdb0..8413020df96f 100644 --- a/fpicker/source/office/OfficeFolderPicker.cxx +++ b/fpicker/source/office/OfficeFolderPicker.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include using namespace ::com::sun::star::container; @@ -70,7 +71,7 @@ void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< css::ui::dial std::shared_ptr SvtFolderPicker::implCreateDialog( weld::Window* pParent ) { - return std::make_shared(pParent, PickerFlags::PathDialog); + return o3tl::make_shared(pParent, PickerFlags::PathDialog); } sal_Int16 SvtFolderPicker::implExecutePicker( ) diff --git a/include/o3tl/make_shared.hxx b/include/o3tl/make_shared.hxx index d42783c301fa..9d7998fd5a36 100644 --- a/include/o3tl/make_shared.hxx +++ b/include/o3tl/make_shared.hxx @@ -10,6 +10,7 @@ #ifndef INCLUDED_O3TL_MAKE_SHARED_HXX #define INCLUDED_O3TL_MAKE_SHARED_HXX +#include #include #include @@ -26,6 +27,20 @@ std::shared_ptr make_shared_array(size_t const size) return std::shared_ptr(new T[size], std::default_delete()); } +/** To markup std::shared_ptr that coverity warns might throw exceptions + which won't throw in practice, or where std::terminate is + an acceptable response if they do +*/ +template +std::shared_ptr make_shared(Args&&... args) +{ +#if defined(__COVERITY__) + return std::shared_ptr(new T(std::forward(args)...), o3tl::default_delete()); +#else + return std::make_shared(std::forward(args)...); +#endif +} + } // namespace o3tl #endif // INCLUDED_O3TL_MAKE_SHARED_HXX diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 3083cf0fd18a..75f5b463a58c 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -66,6 +66,7 @@ #include #include +#include #include using namespace com::sun::star; @@ -793,7 +794,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) break; case SID_DATA_PROVIDER: { - std::shared_ptr xDoc(new ScDocument, o3tl::default_delete()); + auto xDoc = o3tl::make_shared(); xDoc->InsertTab(0, "test"); ScDocument* pDoc = GetViewData()->GetDocument(); ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, pDoc); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 432bbb670675..19b99ec93aa8 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -71,6 +71,7 @@ #include #include +#include #include void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew ) @@ -397,7 +398,7 @@ std::shared_ptr ScTabViewShell::CreateRefDialogCont if (!isLOKMobilePhone()) { // dialog checks, what is in the cell - xResult = std::make_shared(pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr()); + xResult = o3tl::make_shared(pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr()); } break; } diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 68ad3415a08a..05e78a46c332 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -99,7 +99,7 @@ #include #include #include -#include +#include #include #include #include @@ -1013,7 +1013,7 @@ void SwUiWriterTest::testExportRTF() pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false); // Create the clipboard document. - std::shared_ptr xClpDoc(new SwDoc, o3tl::default_delete()); + auto xClpDoc = o3tl::make_shared(); xClpDoc->SetClipBoard(true); pWrtShell->Copy(xClpDoc.get()); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index e06663706d6e..925ec4a34952 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -1361,7 +1361,7 @@ bool ImpGraphic::swapOut() const INetURLObject aTempFileURL(aTempFile.GetURL()); // Create a swap file - std::shared_ptr pSwapFile(new ImpSwapFile(aTempFileURL, getOriginURL()), o3tl::default_delete()); + auto pSwapFile = o3tl::make_shared(aTempFileURL, getOriginURL()); bool bResult = false;