From d173599d0b4667d44aa31991ccb917b1d141412e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 23 Sep 2019 17:38:33 +0200 Subject: tdf#127652 sw_redlinehide: don't set invalid SwTextFrame offsets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The obvious problem here is that if a deletion spans multiple text frames, the offset of the 2nd one must not be reduced lower than the start position of the deletion; apparently this fixes the subsequent crashes with stale text portions having now invalid indexes into the string. (regression from 0acde7514e666fc04805fd36503bd174162336ca) Change-Id: Iaf9e2c5ca06ed36dc0e8611891d19c22f7661d34 Reviewed-on: https://gerrit.libreoffice.org/79421 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 9ec2c77046901fdacca77753052b54c81e6bc82c) Reviewed-on: https://gerrit.libreoffice.org/79433 Reviewed-by: Xisco FaulĂ­ --- sw/source/core/text/txtfrm.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 95210cfc1b7a..6e52c931c989 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1803,7 +1803,8 @@ static void lcl_ModifyOfst(SwTextFrame & rFrame, assert(nLen != TextFrameIndex(COMPLETE_STRING)); if (rFrame.IsFollow() && nPos < rFrame.GetOfst()) { - rFrame.ManipOfst( std::max(TextFrameIndex(0), op(rFrame.GetOfst(), nLen)) ); + rFrame.ManipOfst( std::max(nPos, op(rFrame.GetOfst(), nLen)) ); + assert(sal_Int32(rFrame.GetOfst()) <= rFrame.GetText().getLength()); } } -- cgit