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

New commits:
commit b59d2a54e7c46e92344abb5b3334694d0dd1ac09
Author:     Miklos Vajna <[email protected]>
AuthorDate: Mon Dec 22 13:39:01 2025 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Mon Dec 22 15:28:41 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/+/196094
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sw/source/filter/md/wrtmd.cxx b/sw/source/filter/md/wrtmd.cxx
index 4ff8d638b41f..a3b5a23ee2b8 100644
--- a/sw/source/filter/md/wrtmd.cxx
+++ b/sw/source/filter/md/wrtmd.cxx
@@ -148,7 +148,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