sw/source/core/txtnode/txtedt.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
New commits: commit e86f049b0bfede337c875e5f62d27186fcace37f Author: Michael Stahl <mst...@redhat.com> Date: Tue Jul 25 21:20:10 2017 +0200 sw: fix string accesses in SwScanner::NextWord() (related: tdf#109081) getWordBoundary() can return bounds that do not include the starting nPos, if there are ZWSP characters at the starting position. This happens in the bugdoc of tdf#109081 where paragraph starts with 3 ZWSP and then 5 dashes, SwScanner is created from 0 to 1 and bounds are 3 to 8. Change-Id: I5fc41b98568a7211fc7d5f29bb87840371a4c005 (cherry picked from commit af78fa5f0d3d891b9a30e927a3b35c55f03a03a7) Reviewed-on: https://gerrit.libreoffice.org/40502 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index e0c41585bf50..06e4ead70d8b 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -941,8 +941,16 @@ bool SwScanner::NextWord() { aBound.startPos = std::max( aBound.startPos, nStartPos ); aBound.endPos = std::min( aBound.endPos, nEndPos ); - nBegin = aBound.startPos; - nLen = aBound.endPos - nBegin; + if (aBound.endPos < aBound.startPos) + { + nBegin = nEndPos; + nLen = 0; // found word is outside of search interval + } + else + { + nBegin = aBound.startPos; + nLen = aBound.endPos - nBegin; + } } if( ! nLen )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits