From 196d8539d4375ccf60f33b53bd43a92190de99ca Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Fri, 6 Mar 2026 23:16:48 +0100 Subject: [PATCH] sc: fix crash activating embedded Calc spreadsheet in Impress When activating an embedded Calc spreadsheet in an Impress presentation via DoVerb, the ScTabViewShell constructor crashes at the formula-mode-disabling logic. The code calls SfxViewShell::GetFirst() and dynamic_cast's it to ScTabViewShell*, but when the first view is an Impress DrawViewShell, the cast returns nullptr. The assert() guarding this was stripped in release builds, leading to nullptr->GetInputHandler() (SIGSEGV at offset 0xa50). Replace the assert with a proper nullptr check. If the first view isn't a ScTabViewShell, there's no Calc formula mode to cancel. Change-Id: I4b2e8f3c7d1a9e5b0f6c2d4a8e7b3f1c9d5a2e4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201162 Reviewed-by: Miklos Vajna Tested-by: Jenkins CollaboraOffice (cherry picked from commit 9ad2a9703d6b03a334001ce6351db937b6948480) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204887 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- sc/source/ui/view/tabvwsh4.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 7933ff7095ee..11a17e4af235 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -2295,11 +2295,13 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame& rViewFrame, if (pViewShell2 && pViewShell2 == this) { ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); - assert(pTabViewShell); - ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); - if (pInputHdl && pInputHdl->IsFormulaMode()) + if (pTabViewShell) { - pInputHdl->SetMode(SC_INPUT_NONE); + ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler(); + if (pInputHdl && pInputHdl->IsFormulaMode()) + { + pInputHdl->SetMode(SC_INPUT_NONE); + } } }