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 <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna
2025-12-22 18:25:43 +01:00
parent c25c52dd22
commit 43ba6c9ab4
+6 -1
View File
@@ -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();