sfx2/source/appl/appopen.cxx | 5 +++-- sfx2/source/doc/objserv.cxx | 6 +++++- sfx2/source/notebookbar/SfxNotebookBar.cxx | 11 ++++++----- 3 files changed, 14 insertions(+), 8 deletions(-)
New commits: commit 63af9a5047da775442a04a583044712ab92aa9e6 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Apr 26 10:20:56 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Apr 30 10:20:15 2024 +0200 SfxViewFrame::Current() dereferenced without null check found with msvc -analyze and _Ret_maybenull_ Change-Id: Ia377822e93448dc61acd1482d34167c35a46836b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166705 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 95d3e0d478686c7fa84f0bb8c466a1082333a47b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166830 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166876 diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index b3b11d626362..cf72683f679a 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -1040,9 +1040,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if( aFileName.startsWith("#") ) // Mark without URL { SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : nullptr; - if ( !pView ) + if (!pView) pView = SfxViewFrame::Current(); - pView->GetViewShell()->JumpToMark( aFileName.copy(1) ); + if (pView) + pView->GetViewShell()->JumpToMark( aFileName.copy(1) ); rReq.SetReturnValue( SfxViewFrameItem( pView ) ); return; } diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 78c4fd01f667..1964b473f2cc 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -452,6 +452,10 @@ static void sendErrorToLOK(ErrCode error) if (error.GetClass() == ErrCodeClass::NONE) return; + SfxViewShell* pNotifier = SfxViewShell::Current(); + if (!pNotifier) + return; + boost::property_tree::ptree aTree; aTree.put("code", error); aTree.put("kind", ""); @@ -465,7 +469,7 @@ static void sendErrorToLOK(ErrCode error) std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, OString(aStream.str())); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, OString(aStream.str())); } namespace diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 3b33ef7dd781..40c944eb4aff 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -575,11 +575,12 @@ void SfxNotebookBar::ToggleMenubar() void SfxNotebookBar::ReloadNotebookBar(std::u16string_view sUIPath) { - if (SfxNotebookBar::IsActive()) - { - SfxViewShell* pViewShell = SfxViewShell::Current(); - sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame().GetBindings(), sUIPath, true); - } + if (!SfxNotebookBar::IsActive()) + return; + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (!pViewShell) + return; + sfx2::SfxNotebookBar::StateMethod(pViewShell->GetViewFrame().GetBindings(), sUIPath, true); } IMPL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, pViewShell, void)