summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2013-06-26 19:54:50 -0500
committerMichael Stahl <mstahl@redhat.com>2013-06-27 12:42:24 +0000
commitd9ac156b2d651c1305135938a1e828144aa5742b (patch)
treeeec37c83b0828af35058cd39635cdfc362ed2e6f /editeng
parent3f8445b20e416ae913d68a31d522b948fe4b1684 (diff)
coverity#1038307 Negative loop bound
Change-Id: Ib0ca4fc350d84e25283e261cb9f48b0f6f22e81b Reviewed-on: https://gerrit.libreoffice.org/4556 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit2.cxx20
1 files changed, 12 insertions, 8 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index d6e1de54601a..bba2f2a5dcf7 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 );