sw/source/ui/fldui/fldedt.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 3200d8c08e207a71348146775d748a8a319011c1
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Dec 16 14:39:18 2025 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Dec 22 09:49:33 2025 +0100

    sw: fix crash in SwFieldEditDlg's AddressHdl
    
    gdb in the core dump gives:
            #0  0x000073b5e9fd6bb9 in SwFieldType::Which (this=<optimized out>) 
at sw/inc/fldbas.hxx:276
            #1  SwField::GetTypeId (this=0x0) at 
sw/source/core/fields/fldbas.cxx:267
            #2  0x000073b5e911faa4 in SwFieldEditDlg::AddressHdl 
(this=0x4a057e70) at sw/source/ui/fldui/fldedt.cxx:296
            #3  0x000073b5f85de37c in std::function<void ()>::operator()() 
const (this=0x7fffed028930) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/std_function.h:587
            #4  Control::ImplCallEventListenersAndHandler(VclEventId, 
std::function<void ()> const&) (this=<optimized out>, 
nEvent=nEvent@entry=VclEventId::ButtonClick, callHandler=...)
                at vcl/source/control/ctrl.cxx:311
            #5  0x000073b5f85c16c8 in Button::Click (this=<optimized out>) at 
vcl/source/control/button.cxx:130
    
    and
    
            #2  0x000073b5e911faa4 in SwFieldEditDlg::AddressHdl 
(this=0x4a057e70) at sw/source/ui/fldui/fldedt.cxx:296
            296         if (pCurField->GetTypeId() == 
SwFieldTypesEnum::DocumentInfo)
            (gdb) print pCurField
            $2 = (SwField *) 0x0
    
    return early in case we don't have a valid pointer for the current field
    anymore.
    
    Change-Id: Ibc614cc825a0b14cd4f79060d35f6635eb0cdd55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195784
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit fbd29829a3f610f3f3040b38ad73d49c1268d24a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195791
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx
index 9050dac7b4b2..3c1e08744fa3 100644
--- a/sw/source/ui/fldui/fldedt.cxx
+++ b/sw/source/ui/fldui/fldedt.cxx
@@ -300,6 +300,10 @@ IMPL_LINK_NOARG(SwFieldEditDlg, AddressHdl, weld::Button&, 
void)
     SwFieldPage* pTabPage = static_cast<SwFieldPage*>(GetTabPage());
     SwFieldMgr& rMgr = pTabPage->GetFieldMgr();
     SwField *pCurField = rMgr.GetCurField();
+    if (!pCurField)
+    {
+        return;
+    }
 
     if (pCurField->GetTypeId() == SwFieldTypesEnum::DocumentInfo)
         comphelper::dispatchCommand(u".uno:SetDocumentProperties"_ustr, {});

Reply via email to