Kaydet (Commit) 8644d100 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Asserting rtl::O[U]StringBuffer::operator [] preconditions

...and fixing two call-sites.

Change-Id: I8ed8cb189bd5034130b49b2f57156568e6b24716
üst b8c87dee
......@@ -417,7 +417,11 @@ public:
@since LibreOffice 3.5
*/
sal_Char & operator [](sal_Int32 index) { return pData->buffer[index]; }
sal_Char & operator [](sal_Int32 index)
{
assert(index >= 0 && index < pData->length);
return pData->buffer[index];
}
/**
Return a OString instance reflecting the current content
......
......@@ -409,7 +409,11 @@ public:
@since LibreOffice 3.5
*/
sal_Unicode & operator [](sal_Int32 index) { return pData->buffer[index]; }
sal_Unicode & operator [](sal_Int32 index)
{
assert(index >= 0 && index < pData->length);
return pData->buffer[index];
}
/**
Return a OUString instance reflecting the current content
......
......@@ -1522,7 +1522,9 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
OUString aUpperDBNum( rChrCls().uppercase( rString.toString(), nPos-1, aDBNum.getLength() ) );
sal_Unicode cUpper = aUpperNatNum[0];
sal_Int32 nNatNumNum = rString.toString().copy( nPos - 1 + aNatNum.getLength() ).toInt32();
sal_Unicode cDBNum = rString[ nPos - 1 + aDBNum.getLength()];
sal_Unicode cDBNum =
nPos - 1 + aDBNum.getLength() < rString.getLength()
? rString[nPos - 1 + aDBNum.getLength()] : 0;
if ( aUpperNatNum == aNatNum && 0 <= nNatNumNum && nNatNumNum <= 19 )
{
sBuffSymbol.stripStart((sal_Unicode)'[');
......
......@@ -2265,7 +2265,7 @@ static sal_Bool ImplTimeGetValue( const OUString& rStr, Time& rTime,
return sal_False;
nSepPos = aStr.indexOf( rLocaleDataWrapper.getTimeSep() );
if ( aStr[0] == '-' )
if ( !aStr.isEmpty() && aStr[0] == '-' )
bNegative = sal_True;
if ( nSepPos >= 0 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment