Kaydet (Commit) af78fa5f authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 04461743
...@@ -941,8 +941,16 @@ bool SwScanner::NextWord() ...@@ -941,8 +941,16 @@ bool SwScanner::NextWord()
{ {
aBound.startPos = std::max( aBound.startPos, nStartPos ); aBound.startPos = std::max( aBound.startPos, nStartPos );
aBound.endPos = std::min( aBound.endPos, nEndPos ); aBound.endPos = std::min( aBound.endPos, nEndPos );
nBegin = aBound.startPos; if (aBound.endPos < aBound.startPos)
nLen = aBound.endPos - nBegin; {
nBegin = nEndPos;
nLen = 0; // found word is outside of search interval
}
else
{
nBegin = aBound.startPos;
nLen = aBound.endPos - nBegin;
}
} }
if( ! nLen ) if( ! nLen )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment