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 <vmiklos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
(cherry picked from commit 9ad2a9703d6b03a334001ce6351db937b6948480)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204887
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Andras Timar
2026-05-08 11:31:24 +02:00
committed by Xisco Fauli
parent b8459392b3
commit 196d8539d4
+6 -4
View File
@@ -2295,11 +2295,13 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame& rViewFrame,
if (pViewShell2 && pViewShell2 == this)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(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);
}
}
}