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

Norbert Thiebaud nthiebaud at gmail.com
Thu Jun 27 05:42:44 PDT 2013


 editeng/source/editeng/impedit2.cxx |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit d9ac156b2d651c1305135938a1e828144aa5742b
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Wed Jun 26 19:54:50 2013 -0500

    coverity#1038307 Negative loop bound
    
    Change-Id: Ib0ca4fc350d84e25283e261cb9f48b0f6f22e81b
    Reviewed-on: https://gerrit.libreoffice.org/4556
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index d6e1de5..bba2f2a 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1893,15 +1893,19 @@ void ImpEditEngine::InitWritingDirections( sal_Int32 nPara )
 
         size_t nCount = ubidi_countRuns( pBidi, &nError );
 
-        int32_t nStart = 0;
-        int32_t nEnd;
-        UBiDiLevel nCurrDir;
-
-        for ( size_t nIdx = 0; nIdx < nCount; ++nIdx )
+        /* ubidi_countRuns can return -1 in case of error */
+        if(nCount > 0)
         {
-            ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
-            rInfos.push_back( WritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd ) );
-            nStart = nEnd;
+            int32_t nStart = 0;
+            int32_t nEnd;
+            UBiDiLevel nCurrDir;
+
+            for ( size_t nIdx = 0; nIdx < nCount; ++nIdx )
+            {
+                ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
+                rInfos.push_back( WritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd ) );
+                nStart = nEnd;
+            }
         }
 
         ubidi_close( pBidi );


More information about the Libreoffice-commits mailing list