[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source

Michael Stahl mstahl at redhat.com
Wed Aug 2 08:15:53 UTC 2017


 sw/source/core/txtnode/txtedt.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit e86f049b0bfede337c875e5f62d27186fcace37f
Author: Michael Stahl <mstahl at 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 <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at 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 )


More information about the Libreoffice-commits mailing list