summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-25 21:20:10 +0200
committerMichael Stahl <mstahl@redhat.com>2017-07-27 22:08:04 +0200
commitaf78fa5f0d3d891b9a30e927a3b35c55f03a03a7 (patch)
treee8a352a1e9f35cfaba5a403e0699825854e73eff
parent04461743d75f8cffb5906ab52d772089c44a7780 (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
-rw-r--r--sw/source/core/txtnode/txtedt.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 460736fb0975..fa0724c85047 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 )