Skip to content

Commit

Permalink
cppcheck: Array index is used before limits check
Browse files Browse the repository at this point in the history
Change-Id: I51f7408a81a10e2c586cb05b863f20b13bb7b263
  • Loading branch information
serval2412 committed Oct 29, 2013
1 parent 78f2f28 commit a3f0eab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions i18npool/source/nativenumber/nativenumbersupplier.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ OUString SAL_CALL AsciiToNative( const OUString& inStr, sal_Int32 startPos, sal_
srcStr[len++] = str[i];
} else {
if (len > 0) {
if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
if (i < nCount-1 && isSeparator(str[i]) && isNumber(str[i+1]))
continue; // skip comma inside number string
sal_Bool notZero = sal_False;
for (sal_Int32 begin = 0, end = len % number->multiplierExponent[0];
Expand Down Expand Up @@ -224,11 +224,11 @@ OUString SAL_CALL AsciiToNative( const OUString& inStr, sal_Int32 startPos, sal_
len = 0;
}
if (i < nCount) {
if ((doDecimal = (!doDecimal && isDecimal(str[i]) && i < nCount-1 && isNumber(str[i+1]))) != sal_False)
if ((doDecimal = (!doDecimal && i < nCount-1 && isDecimal(str[i]) && isNumber(str[i+1]))) != sal_False)
newStr[count] = (DecimalChar[number->number] ? DecimalChar[number->number] : str[i]);
else if (isMinus(str[i]) && i < nCount-1 && isNumber(str[i+1]))
else if (i < nCount-1 && isMinus(str[i]) && isNumber(str[i+1]))
newStr[count] = (MinusChar[number->number] ? MinusChar[number->number] : str[i]);
else if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
else if (i < nCount-1 && isSeparator(str[i]) && isNumber(str[i+1]))
newStr[count] = (SeparatorChar[number->number] ? SeparatorChar[number->number] : str[i]);
else
newStr[count] = str[i];
Expand Down
2 changes: 1 addition & 1 deletion sc/source/ui/optdlg/tpusrlst.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void ScTpUserLists::MakeListStr( OUString& rListStr )
{
rListStr += OUString(aStr[c]);

while ( (aStr[c] == cDelimiter) && (c < nLen) )
while ( (c < nLen) && (aStr[c] == cDelimiter) )
c++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sw/source/ui/docvw/srcedtw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void lcl_Highlight(const OUString& rSource, SwTextPortions& aPortionList)
while(nActPos < nStrLen)
{
svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN;
if(rSource[nActPos] == cOpenBracket && nActPos < nStrLen - 2 )
if((nActPos < nStrLen - 2) && (rSource[nActPos] == cOpenBracket))
{
// insert 'empty' portion
if(nPortEnd < nActPos - 1 )
Expand Down

0 comments on commit a3f0eab

Please sign in to comment.