diff options
-rw-r--r-- | basegfx/source/polygon/b2dsvgpolypolygon.cxx | 12 | ||||
-rw-r--r-- | basic/source/comp/scanner.cxx | 17 | ||||
-rw-r--r-- | basic/source/comp/token.cxx | 5 | ||||
-rw-r--r-- | include/rtl/ustring.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 2 | ||||
-rw-r--r-- | svl/source/misc/urihelper.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/edit/edattr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/pormulti.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 2 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/mnemonic.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/draw/xexptran.cxx | 34 | ||||
-rw-r--r-- | xmloff/source/style/fonthdl.cxx | 2 |
18 files changed, 70 insertions, 52 deletions
diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index ffb04913076e..d9b869b248b8 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -88,24 +88,28 @@ namespace basegfx { if (sal_Unicode('.') == aChar) separator_seen = true; sNumberString.append(rStr[io_rPos]); - aChar = rStr[++io_rPos]; + io_rPos++; + aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0; } if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar) { sNumberString.append(rStr[io_rPos]); - aChar = rStr[++io_rPos]; + io_rPos++; + aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0; if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) { sNumberString.append(rStr[io_rPos]); - aChar = rStr[++io_rPos]; + io_rPos++; + aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0; } while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) { sNumberString.append(rStr[io_rPos]); - aChar = rStr[++io_rPos]; + io_rPos++; + aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0; } } diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 0a5a4932f99f..3609765b3630 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -401,13 +401,16 @@ bool SbiScanner::NextSym() GenError( SbERR_MATH_OVERFLOW ); // type recognition? - SbxDataType t(GetSuffixType(aLine[nCol])); - if( t != SbxVARIANT ) + if( nCol < aLine.getLength() ) { - eScanType = t; - ++pLine; - ++nCol; - } + SbxDataType t(GetSuffixType(aLine[nCol])); + if( t != SbxVARIANT ) + { + eScanType = t; + ++pLine; + ++nCol; + } + } } // Hex/octal number? Read in and convert: @@ -531,7 +534,7 @@ bool SbiScanner::NextSym() PrevLineCommentLbl: if( bPrevLineExtentsComment || (eScanType != SbxSTRING && - ( aSym[0] == '\'' || aSym.equalsIgnoreAsciiCase( "REM" ) ) ) ) + ( aSym.startsWith("'") || aSym.equalsIgnoreAsciiCase( "REM" ) ) ) ) { bPrevLineExtentsComment = false; aSym = OUString("REM"); diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index beff37d7f6c3..bf5231a0a571 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -344,9 +344,10 @@ SbiToken SbiTokenizer::Next() return eCurTok = EOLN; } - if( aSym[0] == '\n' ) + if( aSym.startsWith("\n") ) { - bEos = true; return eCurTok = EOLN; + bEos = true; + return eCurTok = EOLN; } bEos = false; diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index ba8c3588aa58..45a7441f9591 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -417,11 +417,7 @@ public: @since LibreOffice 3.5 */ sal_Unicode operator [](sal_Int32 index) const { - assert(index >= 0 && index <= getLength()); - //TODO: should really check for < getLength(), but there is quite - // some clever code out there that violates this function's - // documented precondition and relies on s[s.getLength()] == 0 and - // that would need to be fixed first + assert(index >= 0 && index < getLength()); return getStr()[index]; } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 61aa6373b6b8..73a514b87a16 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2161,7 +2161,7 @@ bool ScTable::CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 { bFound = false; GetUpperCellString(nCol1 + 2, nRow, aCellStr); - if (aCellStr[0] == '<') + if (aCellStr.startsWith("<")) { if (aCellStr[1] == '>') rEntry.eOp = SC_NOT_EQUAL; @@ -2170,14 +2170,14 @@ bool ScTable::CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 else rEntry.eOp = SC_LESS; } - else if (aCellStr[0] == '>') + else if (aCellStr.startsWith(">")) { if (aCellStr[1] == '=') rEntry.eOp = SC_GREATER_EQUAL; else rEntry.eOp = SC_GREATER; } - else if (aCellStr[0] == '=') + else if (aCellStr.startsWith("=")) rEntry.eOp = SC_EQUAL; } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index ac858709a1be..cd8a47b592ec 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -3022,7 +3022,7 @@ sal_Int32 ScXMLImport::GetRangeType(const OUString sRangeType) const sal_Int16 i = 0; while (i <= sRangeType.getLength()) { - if ((sRangeType[i] == ' ') || (i == sRangeType.getLength())) + if ((i == sRangeType.getLength()) || (sRangeType[i] == ' ')) { OUString sTemp = sBuffer.makeStringAndClear(); if (sTemp.compareToAscii(SC_REPEAT_COLUMN) == 0) diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index 32df0b69748a..f147f1a810a3 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -527,7 +527,7 @@ OUString URIHelper::FindFirstURLInText(OUString const & rText, while (i != rEnd && checkWChar(rCharClass, rText, &i, &nUriEnd, true, true)) ; - if (i != nPrefixEnd && rText[i] == (sal_Unicode)'#') + if (i != nPrefixEnd && i != rEnd && rText[i] == '#') { ++i; while (i != rEnd @@ -555,7 +555,7 @@ OUString URIHelper::FindFirstURLInText(OUString const & rText, sal_Int32 nUriEnd = i; while (i != rEnd && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - if (i != nPrefixEnd && rText[i] == '#') + if (i != nPrefixEnd && i != rEnd && rText[i] == '#') { ++i; while (i != rEnd diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 3a4ba43c6de4..962f5268aa44 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -70,11 +70,11 @@ namespace SwTxtNode const*const pStartTxtNode = rStart.nNode.GetNode().GetTxtNode(); SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode(); - const sal_Unicode ch_start = + const sal_Unicode ch_start = ( rStart.nContent.GetIndex() >= pStartTxtNode->GetTxt().getLength() ) ? 0 : pStartTxtNode->GetTxt()[rStart.nContent.GetIndex()]; xub_StrLen nEndPos = ( rEnd == rStart || rEnd.nContent.GetIndex() == 0 ) ? rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1; - const sal_Unicode ch_end = pEndTxtNode->GetTxt()[nEndPos]; + const sal_Unicode ch_end = nEndPos >= pEndTxtNode->GetTxt().getLength() ? 0 : pEndTxtNode->GetTxt()[nEndPos]; SwPaM aStartPaM(rStart); SwPaM aEndPaM(rEnd); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index d9cfcadcf0e5..8e01455bd693 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -493,7 +493,7 @@ static bool lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, } // and fields - if (CH_TXTATR_BREAKWORD == rTNd.GetTxt()[nPos]) + if (nPos < rTNd.GetTxt().getLength() && CH_TXTATR_BREAKWORD == rTNd.GetTxt()[nPos]) { const SwTxtAttr* const pAttr = rTNd.GetTxtAttrForCharAt( nPos ); if (pAttr) diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 180b240f64a7..5c284615b92c 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2027,7 +2027,7 @@ sal_Bool SwTxtFormatter::AllowRepaintOpt() const const xub_StrLen nReformat = GetInfo().GetReformatStart(); if( bOptimizeRepaint && STRING_LEN != nReformat ) { - const sal_Unicode cCh = GetInfo().GetTxt()[ nReformat ]; + const sal_Unicode cCh = nReformat >= GetInfo().GetTxt().getLength() ? 0 : GetInfo().GetTxt()[ nReformat ]; bOptimizeRepaint = ( CH_TXTATR_BREAKWORD != cCh && CH_TXTATR_INWORD != cCh ) || ! GetInfo().HasHint( nReformat ); } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index ab18a829ad7e..9c1c05731ea1 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -885,7 +885,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, sal_uInt8 nNextLevel = nCurrLevel; bool bFldBidi = false; - if ( CH_TXTATR_BREAKWORD == GetChar( rPos ) ) + if ( rPos < GetTxt().getLength() && CH_TXTATR_BREAKWORD == GetChar( rPos ) ) { bFldBidi = true; } diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 03dbba33344a..acb60ef8dc07 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -648,7 +648,7 @@ xub_StrLen SwTxtFrm::FindBrk( const OUString &rTxt, const sal_Int32 nEnd ) const { sal_Int32 nFound = nStart; - const sal_Int32 nEndLine = std::min( nEnd, rTxt.getLength() ); + const sal_Int32 nEndLine = std::min( nEnd, rTxt.getLength() - 1 ); // Wir ueberlesen erst alle Blanks am Anfang der Zeile (vgl. Bug 2235). while( nFound <= nEndLine && ' ' == rTxt[nFound] ) diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index 35be5fa6acfc..af8c32ea7d37 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -827,9 +827,9 @@ namespace sw if (!(IsPreviousAM(rParams, nI) && IsNextPM(rParams, nI))) { rParams = rParams.replaceAt(nI, 1, "\\/"); + nLen++; } nI++; - nLen++; } // Deal with language differences in date format expression. diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index b688de1ec756..32babd9b7a6a 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -2045,16 +2045,16 @@ namespace { // Muessen wir Konvertieren if ( ((eLineEnd != LINEEND_LF) && (rIn[i] == '\n')) || - ((eLineEnd == LINEEND_CRLF) && (rIn[i+1] != '\n')) || + ((eLineEnd == LINEEND_CRLF) && (i+1) < nStrLen && (rIn[i+1] != '\n')) || ((eLineEnd == LINEEND_LF) && - ((rIn[i] == '\r') || (rIn[i+1] == '\r'))) || + ((rIn[i] == '\r') || ((i+1) < nStrLen && rIn[i+1] == '\r'))) || ((eLineEnd == LINEEND_CR) && - ((rIn[i] == '\n') || (rIn[i+1] == '\n'))) ) + ((rIn[i] == '\n') || ((i+1) < nStrLen && rIn[i+1] == '\n'))) ) bConvert = true; } - // skip char if \r\n oder \n\r - if ( ((rIn[i+1] == '\r') || (rIn[i+1] == '\n')) && + // skip char if \r\n or \n\r + if ( (i+1) < nStrLen && ((rIn[i+1] == '\r') || (rIn[i+1] == '\n')) && (rIn[i] != rIn[i+1]) ) ++i; } @@ -2087,7 +2087,7 @@ namespace aNewData.append('\n'); } - if ( ((rIn[i+1] == '\r') || (rIn[i+1] == '\n')) && + if ( (i+1) < nStrLen && ((rIn[i+1] == '\r') || (rIn[i+1] == '\n')) && (rIn[i] != rIn[i+1]) ) ++i; } diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index a9de9725edfe..d8ec0e69aef1 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -4843,7 +4843,7 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, nBreakPos++; nPos = nBreakPos; - if ( ( rStr[ nPos ] == '\r' ) || ( rStr[ nPos ] == '\n' ) ) + if ( nPos < nLen && ( ( rStr[ nPos ] == '\r' ) || ( rStr[ nPos ] == '\n' ) ) ) { nPos++; // CR/LF? diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx index 0b55245d146b..fe45ae8928cd 100644 --- a/vcl/source/window/mnemonic.cxx +++ b/vcl/source/window/mnemonic.cxx @@ -208,14 +208,14 @@ OUString MnemonicGenerator::CreateMnemonic( const OUString& _rKey ) } // Search for next word - do + nIndex++; + while ( nIndex < nLen ) { - nIndex++; c = aKey[ nIndex ]; if ( c == ' ' ) break; + nIndex++; } - while ( nIndex < nLen ); nIndex++; } while ( nIndex < nLen ); diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index f97aaacc41bb..5f131251f6ee 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -151,24 +151,33 @@ void Imp_SkipDouble(const OUString& rStr, sal_Int32& rPos, const sal_Int32) sal_Unicode aChar(rStr[rPos]); if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) - aChar = rStr[++rPos]; + { + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; + } while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) || sal_Unicode('.') == aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; } if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) - aChar = rStr[++rPos]; + { + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; + } while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) { - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= rStr.getLength() ? 0 : rStr[rPos]; } } } @@ -182,31 +191,36 @@ double Imp_GetDoubleChar(const OUString& rStr, sal_Int32& rPos, const sal_Int32 if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) || sal_Unicode('.') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) { sNumberString.append(rStr[rPos]); - aChar = rStr[++rPos]; + ++rPos; + aChar = rPos >= nLen ? 0 : rStr[rPos]; } } diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index a2768e565639..b61803a04afb 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -81,7 +81,7 @@ bool XMLFontFamilyNamePropHdl::importXML( const OUString& rStrImpValue, uno::Any nFirst++; // remove quotes - sal_Unicode c = rStrImpValue[nFirst]; + sal_Unicode c = nFirst > nLast ? 0 : rStrImpValue[nFirst]; if( nFirst < nLast && (sal_Unicode('\'') == c || sal_Unicode('\"') == c) && rStrImpValue[nLast] == c ) { nFirst++; |