diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-01-27 12:48:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-01-27 14:38:37 +0000 |
commit | 01c28e33bf9144a377f29e32bb1bce607cb0d8b9 (patch) | |
tree | 0e2f0446d445d071f6d9d676bcded4ca60b72d31 /basctl | |
parent | 391cb2a6c5f4f36e26ed9eb5d05da1123797cff4 (diff) |
coverity#1130421 Improper use of negative value
Change-Id: Iefdd854cb0348b187b95f4a89d52482381c73dfc
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index da1cac7e2a08..5194385df519 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -664,22 +664,23 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra DBG_ASSERTWARNING( nStartPos != -1, "CutLines: Startzeile nicht gefunden!" ); - if ( nStartPos != -1 ) - { - sal_Int32 nEndPos = nStartPos; + if ( nStartPos == -1 ) + return; - for ( sal_Int32 i = 0; i < nLines; i++ ) - nEndPos = searchEOL( rStr, nEndPos+1 ); + sal_Int32 nEndPos = nStartPos; - if ( nEndPos == -1 ) // might happen at the last line - nEndPos = rStr.getLength(); - else - nEndPos++; + for ( sal_Int32 i = 0; i < nLines; i++ ) + nEndPos = searchEOL( rStr, nEndPos+1 ); + + if ( nEndPos == -1 ) // might happen at the last line + nEndPos = rStr.getLength(); + else + nEndPos++; + + OUString aEndStr = rStr.copy( nEndPos ); + rStr = rStr.copy( 0, nStartPos ); + rStr += aEndStr; - OUString aEndStr = rStr.copy( nEndPos ); - rStr = rStr.copy( 0, nStartPos ); - rStr += aEndStr; - } if ( bEraseTrailingEmptyLines ) { sal_Int32 n = nStartPos; @@ -692,7 +693,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEra if ( n > nStartPos ) { - OUString aEndStr = rStr.copy( n ); + aEndStr = rStr.copy( n ); rStr = rStr.copy( 0, nStartPos ); rStr += aEndStr; } |