[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Fri Nov 17 09:10:13 UTC 2017


 sw/source/core/text/porlay.cxx |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

New commits:
commit 6e686439291b4047a8c522ebf78d25632d349f62
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 16 14:19:16 2017 +0000

    Resolves: tdf#113871 bounds check kashida pos
    
    the inner loop checks the kashida validity so reuse the
    same check outside to avoid index 3 into vector of len 3
    
    Change-Id: I27c30aec1a61ccc8ca6611498d3281eddb4b54eb
    Reviewed-on: https://gerrit.libreoffice.org/44831
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Martin Hosken <martin_hosken at sil.org>

diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 2d23d2aa9710..f075d2efb93d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1731,11 +1731,10 @@ sal_Int32 SwScriptInfo::KashidaJustify( long* pKernArray,
     if ( nCntKash < CountKashida() )
     {
         // skip any invalid kashidas
-        while ( ! IsKashidaValid ( nCntKash ) && nCntKash < nCntKashEnd )
+        while (nCntKash < nCntKashEnd && !IsKashidaValid(nCntKash))
             ++nCntKash;
 
-        sal_Int32 nKashidaPos = GetKashida( nCntKash );
-        sal_Int32 nIdx = nKashidaPos;
+        sal_Int32 nIdx = nCntKash < nCntKashEnd && IsKashidaValid(nCntKash) ? GetKashida(nCntKash) : nEnd;
         long nKashAdd = nSpaceAdd;
 
         while ( nIdx < nEnd )
@@ -1744,10 +1743,10 @@ sal_Int32 SwScriptInfo::KashidaJustify( long* pKernArray,
 
             // next kashida position
             ++nCntKash;
-            while ( ! IsKashidaValid ( nCntKash ) && nCntKash < nCntKashEnd )
+            while (nCntKash < nCntKashEnd && !IsKashidaValid(nCntKash))
                 ++nCntKash;
 
-            nIdx = nCntKash < CountKashida() && IsKashidaValid ( nCntKash ) ? GetKashida( nCntKash ) : nEnd;
+            nIdx = nCntKash < nCntKashEnd && IsKashidaValid(nCntKash) ? GetKashida(nCntKash) : nEnd;
             if ( nIdx > nEnd )
                 nIdx = nEnd;
 


More information about the Libreoffice-commits mailing list