sw/source/filter/md/wrtmd.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 43ba6c9ab4f1f29b40633fd9342127c2868547df
Author:     Miklos Vajna <[email protected]>
AuthorDate: Mon Dec 22 13:39:01 2025 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Dec 22 18:25:43 2025 +0100

    sw markdown export: fix crash in ApplyFlyFrameFormat()
    
    gdb backtrace on the crashreport core dump:
    
            #0  SwNodeIndex::GetIndex (this=0x0) at sw/inc/ndindex.hxx:109
            #1  (anonymous namespace)::ApplyFlyFrameFormat (rFrameFormat=..., 
rWrt=..., rChange=...)
                at sw/source/filter/md/wrtmd.cxx:151
            #2  0x000072427b5880dd in (anonymous namespace)::ApplyItem 
(rWrt=..., rChange=..., rItem=..., increment=<optimized out>)
                at sw/source/filter/md/wrtmd.cxx:280
            #3  0x000072427b58888b in (anonymous 
namespace)::CalculateFormattingChange (currentFormatting=..., pos=0, 
positions=..., rWrt=...)
                at sw/source/filter/md/wrtmd.cxx:323
            #4  (anonymous namespace)::OutFormattingChange (rWrt=..., 
positions=..., pos=pos@entry=0, current=...)
                at sw/source/filter/md/wrtmd.cxx:385
            #5  0x000072427b58ad66 in (anonymous 
namespace)::OutMarkdown_SwTextNode (rWrt=..., rNode=..., bFirst=<optimized out>)
                at sw/source/filter/md/wrtmd.cxx:821
            #6  0x000072427b58b8e7 in SwMDWriter::Out_SwDoc 
(this=this@entry=0x4229cea0, pPam=<optimized out>)
                at sw/source/filter/md/wrtmd.cxx:1063
    
    If there is no start node in the SwFormatContent, then we have no way to
    access the Graphic to export, so just return early.
    
    Change-Id: I3c2e4b256aa63c415bb224246f0ce2fc4f3e5059
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196102
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/filter/md/wrtmd.cxx b/sw/source/filter/md/wrtmd.cxx
index a2485d863cff..763ac8dcf027 100644
--- a/sw/source/filter/md/wrtmd.cxx
+++ b/sw/source/filter/md/wrtmd.cxx
@@ -158,7 +158,12 @@ void ApplyFlyFrameFormat(const SwFlyFrameFormat& 
rFrameFormat, SwMDWriter& rWrt,
                          FormattingStatus& rChange)
 {
     const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
-    SwNodeOffset nStart = rFlyContent.GetContentIdx()->GetIndex() + 1;
+    const SwNodeIndex* pContentIdx = rFlyContent.GetContentIdx();
+    if (!pContentIdx)
+    {
+        return;
+    }
+    SwNodeOffset nStart = pContentIdx->GetIndex() + 1;
     Graphic aGraphic;
     OUString aGraphicURL;
     SwNodeType eNodeType = rWrt.m_pDoc->GetNodes()[nStart]->GetNodeType();

Reply via email to