diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-04-15 19:30:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-04-15 22:17:19 +0200 |
commit | 5d111672ae58e35b7856bc2578352ebdc3ab6ecd (patch) | |
tree | d7c204f901d4d81e40604b25161095c38a16a6ce /sfx2 | |
parent | faadf7c15593521c0ebceb043f82f916ee5ccf9d (diff) |
null-deref in SfxViewShell::isBlockedCommand
Change-Id: I43db7fabcc32971f951cc72dc9b1d22eba8df357
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166094
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 25 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 2 |
2 files changed, 15 insertions, 12 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index f49dc2d7336f..9cbd29034a46 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -532,18 +532,21 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, SolarMutexGuard aGuard; - if (comphelper::LibreOfficeKit::isActive() && - SfxViewShell::Current()->isBlockedCommand(aURL.Complete)) + if (comphelper::LibreOfficeKit::isActive()) { - tools::JsonWriter aTree; - aTree.put("code", ""); - aTree.put("kind", "BlockedCommand"); - aTree.put("cmd", aURL.Complete); - aTree.put("message", "Blocked feature"); - aTree.put("viewID", SfxViewShell::Current()->GetViewShellId().get()); - - SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_COMMAND_BLOCKED, aTree.finishAndGetAsOString()); - return; + const SfxViewShell* pViewShell = SfxViewShell::Current(); + if (pViewShell && pViewShell->isBlockedCommand(aURL.Complete)) + { + tools::JsonWriter aTree; + aTree.put("code", ""); + aTree.put("kind", "BlockedCommand"); + aTree.put("cmd", aURL.Complete); + aTree.put("message", "Blocked feature"); + aTree.put("viewID", pViewShell->GetViewShellId().get()); + + pViewShell->libreOfficeKitViewCallback(LOK_COMMAND_BLOCKED, aTree.finishAndGetAsOString()); + return; + } } if ( diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 0c800e1092d7..52761a1fb5fb 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -3908,7 +3908,7 @@ void SfxViewShell::setBlockedCommandList(const char* blockedCommandList) } } -bool SfxViewShell::isBlockedCommand(OUString command) +bool SfxViewShell::isBlockedCommand(OUString command) const { return mvLOKBlockedCommandList.find(command) != mvLOKBlockedCommandList.end(); } |