summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-04-12 08:52:43 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-13 16:52:50 +0200
commit1e605412df2ca9aab895b34f256ccd5a8dfdc83d (patch)
tree164879afa365a039e9f488cbc6ffe7a33e0408c7
parentfd19637cfd4099a96661a071939576bc7db4946a (diff)
sfx2: fix crash in InterceptLOKStateChangeEvent()
Notice how e.g. the TransformPosX case already performed the same null pointer check. Crashreport backtrace: > program/libmergedlo.so > InterceptLOKStateChangeEvent > sfx2/source/control/unoctitm.cxx:1143 > program/libmergedlo.so > SfxStateCache::SetState_Impl(SfxItemState, SfxPoolItem const*, bool) > sfx2/source/control/statcach.cxx:432 > program/libmergedlo.so > SfxBindings::Update_Impl(SfxStateCache&) > /opt/rh/devtoolset-10/root/usr/include/c++/10/bits/stl_vector.h:919 (discriminator 2) > program/libmergedlo.so > SfxBindings::NextJob_Impl(Timer const*) > /opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:173 Change-Id: I141d4f9ec50d0ce7a0eeaba69752c31390a1f9ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166027 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166046 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r--sfx2/source/control/unoctitm.cxx18
1 files changed, 11 insertions, 7 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 333879c24d0f..f49dc2d7336f 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1118,13 +1118,17 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
else if (aEvent.FeatureURL.Path == "ParaLeftToRight" ||
aEvent.FeatureURL.Path == "ParaRightToLeft")
{
- tools::JsonWriter aTree;
- bool bTemp = false;
- aEvent.State >>= bTemp;
- aTree.put("commandName", aEvent.FeatureURL.Complete);
- aTree.put("disabled", !aEvent.IsEnabled);
- aTree.put("state", bTemp ? "true" : "false");
- SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aTree.finishAndGetAsOString());
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (pViewShell)
+ {
+ tools::JsonWriter aTree;
+ bool bTemp = false;
+ aEvent.State >>= bTemp;
+ aTree.put("commandName", aEvent.FeatureURL.Complete);
+ aTree.put("disabled", !aEvent.IsEnabled);
+ aTree.put("state", bTemp ? "true" : "false");
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aTree.finishAndGetAsOString());
+ }
return;
}
else if (aEvent.FeatureURL.Path == "AssignLayout" ||