formula/source/ui/dlg/formula.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 54dca662577bf7267e1d993650c353ef10a88e36
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Apr 18 13:31:42 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Apr 26 13:20:36 2023 +0200

    formula: fix crash in FormulaDlg_Impl::UpdateSelection
    
    m_pFuncDesc can be nullptr
    
    See 
https://crashreport.libreoffice.org/stats/signature/formula::FormulaDlg_Impl::UpdateSelection()
    
    Change-Id: If8a95bef8b0a8a03ffe63041409ee7c1cf322b0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150550
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 2d62a54d151f32007c1cb1c7f729b777dbdb73cc)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150569
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/formula/source/ui/dlg/formula.cxx 
b/formula/source/ui/dlg/formula.cxx
index c73543603158..5b6ef7000fe9 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -1456,15 +1456,23 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaCursorHdl, 
weld::TextView&, void)
 void FormulaDlg_Impl::UpdateSelection()
 {
     m_pHelper->setSelection( m_aFuncSel.Min(), m_aFuncSel.Max());
-    m_pHelper->setCurrentFormula( m_pFuncDesc->getFormula( m_aArguments ) );
+    if (m_pFuncDesc)
+    {
+        m_pHelper->setCurrentFormula( m_pFuncDesc->getFormula( m_aArguments ) 
);
+        m_nArgs = m_pFuncDesc->getSuppressedArgumentCount();
+    }
+    else
+    {
+        m_pHelper->setCurrentFormula("");
+        m_nArgs = 0;
+    }
+
     m_xMEdit->set_text(m_pHelper->getCurrentFormula());
     sal_Int32 PrivStart, PrivEnd;
     m_pHelper->getSelection( PrivStart, PrivEnd);
     m_aFuncSel.Min() = PrivStart;
     m_aFuncSel.Max() = PrivEnd;
 
-    m_nArgs = m_pFuncDesc->getSuppressedArgumentCount();
-
     OUString aFormula = m_xMEdit->get_text();
     sal_Int32 nArgPos = m_aFormulaHelper.GetArgStart( aFormula, PrivStart, 0);
 

Reply via email to