diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-07-25 21:20:10 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-02 10:15:03 +0200 |
commit | e86f049b0bfede337c875e5f62d27186fcace37f (patch) | |
tree | 621aa57b46a671b440c5a51c4ff521c235990ff8 /sw | |
parent | dbd147d3acbe537d56765b966ae5003e51172c19 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
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 ) |