diff options
-rw-r--r-- | sal/inc/rtl/strbuf.hxx | 6 | ||||
-rw-r--r-- | sal/inc/rtl/ustrbuf.hxx | 6 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 2 |
4 files changed, 14 insertions, 4 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 4dabc7653e7b..d858c89023da 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -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 diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index 95993fc4a12c..abbf3d01ade5 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -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 diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index ee1a27d0c690..73cc37c84703 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -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)'['); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index b988cb83cc11..8b9972d09aeb 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -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 ) { |