diff options
author | Justin Luth <justin_luth@sil.org> | 2021-01-15 20:32:43 +0300 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-01-18 13:48:07 +0100 |
commit | 008dc7a128c1f49093eefadc83c125c3c6b1bb00 (patch) | |
tree | de8822815462c64d6c7187809667e036149134a6 /sw | |
parent | 8c0157fc1c971e2ddf7f851510ecb94e61aa9eb9 (diff) |
tdf#136704 sw autofmt: prevent crash if no nextNode
The second GetNextNode() was a nullptr
that was being dereferenced.
Now, when enter is pressed after some text followed by a colon,
that line is made into a heading3, and the new blank line is
properly using the text body paragraph style.
Change-Id: If10dc85e490ac57fc150b3d541f5033dfd5293bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109413
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit fea7b531a4c9e8326a644cccc26325b16585675a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109520
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 7588104d5c7f..5c3e22aaed4a 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1896,11 +1896,14 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) JoinPrevPara(); DeleteLeadingTrailingBlanks( true, false ); - const SwTextFrame *const pNextFrame = GetNextNode(false); - (void)DeleteJoinCurNextPara(pNextFrame, true); - + const SwTextFrame* pNextFrame = GetNextNode(false); + if (pNextFrame->GetNext()) + { + (void)DeleteJoinCurNextPara(pNextFrame, true); + pNextFrame = GetNextNode(false); + } m_aDelPam.DeleteMark(); - m_aDelPam.GetPoint()->nNode = *GetNextNode(false)->GetTextNodeForParaProps(); + m_aDelPam.GetPoint()->nNode = *pNextFrame->GetTextNodeForParaProps(); m_aDelPam.GetPoint()->nContent.Assign( m_aDelPam.GetContentNode(), 0 ); m_pDoc->SetTextFormatColl( m_aDelPam, &rNxtColl ); } |