sw/source/core/text/itrcrsr.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
New commits: commit 029540bf5f31397cf5467c822869e22c0d90b2c0 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Jan 11 21:46:01 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Jan 12 01:32:32 2025 +0100 crashtesting: assert on reloading .docx output of fdo60683-2.odt maybe since: commit 8cb4db941f91cc234dd18c61f8b1e51f65360d1f CommitDate: Wed Aug 31 08:29:49 2022 +0200 tdf#30731: Improve caret travelling in Writer #3 0x00007ffff74dabf0 in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () at /lib64/libstdc++.so.6 #4 0x00007fffce3e97b3 in std::clamp<int> (__val=@0x7ffffffe52b4: 1897, __lo=@0x7ffffffe51f0: 1900, __hi=@0x7ffffffe51e8: 1897) at /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_algo.h:3625 #5 0x00007fffce3e41ff in GetTextArray (rDevice=..., rStr='x' <repeats 200 times>..., rDXAry=std::__debug::vector of length 0, capacity 0, nIndex=1875, nLen=25, nLayoutContext=std::optional = {...}, nMaxAscent=0x7ffffffe5680, nMaxDescent=0x7ffffffe5678, bCaret=true, layoutCache=0x0) at core/sw/source/core/txtnode/fntcache.cxx:763 #6 0x00007fffce3e2a47 in SwFntObj::GetTextSize (this=0x6134340, rInf=...) at core/sw/source/core/txtnode/fntcache.cxx:1734 #7 0x00007fffce461147 in SwSubFont::GetTextSize_ (this=0x6281450, rInf=...) at core/sw/source/core/txtnode/swfont.cxx:1039 #8 0x00007fffce1f953c in SwFont::GetTextSize_ (this=0x6281450, rInf=...) at sw/source/core/inc/swfont.hxx:321 #9 0x00007fffce2234e2 in SwTextSizeInfo::GetTextSize (this=0x7ffffffe6b80, nLayoutContext=std::optional = {...}) at core/sw/source/core/text/inftxt.cxx:439 #10 0x00007fffce2f2217 in SwTextPortion::GetTextSize (this=0x62a3d40, rInf=...) at core/sw/source/core/text/portxt.cxx:586 #11 0x00007fffce250b8c in SwTextCursor::GetCharRect_ (this=0x7ffffffe6fc8, pOrig=0x7ffffffe81c8, nOfst=..., pCMS=0x7ffffffe6e20) at core/sw/source/core/text/itrcrsr.cxx:956 #12 0x00007fffce24d978 in SwTextCursor::GetCharRect (this=0x7ffffffe6fc8, pOrig=0x7ffffffe81c8, nOfst=..., pCMS=0x7ffffffe6e20, nMax=20604) at core/sw/source/core/text/itrcrsr.cxx:1281 #13 0x00007fffce1f08c1 in SwTextFrame::GetAutoPos (this=0x6259250, rOrig=SwRect = {...}, rPos=SwPosition (node 28, offset 1897)) at core/sw/source/core/text/frmcrsr.cxx:430 Change-Id: I8230c9cbb99126b513bea38517b1dbfac5a50f4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180131 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 00dfa384029f..ddb54f8eb0d6 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -937,7 +937,8 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, // give the wrong width if nOfst is in e.g. the middle // of a ligature. See SwFntObj::DrawText(). TextFrameIndex const nOldLen = pPor->GetLen(); - aInf.SetLen( pPor->GetLen() ); + TextFrameIndex nMaxLen = TextFrameIndex(aInf.GetText().getLength()) - aInf.GetIdx(); + aInf.SetLen( std::min(nMaxLen, pPor->GetLen()) ); pPor->SetLen( nOfst - aInf.GetIdx() ); aInf.SetMeasureLen(pPor->GetLen()); if (aInf.GetLen() < aInf.GetMeasureLen())