diff options
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 6 | ||||
-rw-r--r-- | sal/inc/rtl/string.hxx | 9 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 9 |
3 files changed, 20 insertions, 4 deletions
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 052f9705ab1e..364087d4e9e3 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -194,7 +194,8 @@ sal_Bool LngParser::Merge( { rtl::OString sLine( *(*pLines)[ nPos ] ); sLine = sLine.trim(); - if (( sLine[0] == '[' ) && + if (!sLine.isEmpty() && + ( sLine[0] == '[' ) && ( sLine[sLine.getLength() - 1] == ']' )) { sGroup = getBracketedContent(sLine).trim(); @@ -220,7 +221,8 @@ sal_Bool LngParser::Merge( { rtl::OString sLine( *(*pLines)[ nPos ] ); sLine = sLine.trim(); - if (( sLine[0] == '[' ) && + if (!sLine.isEmpty() && + ( sLine[0] == '[' ) && ( sLine[sLine.getLength() - 1] == ']' )) { sGroup = getBracketedContent(sLine).trim(); diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index f6cec59dc04e..f9eeda2d7799 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -388,7 +388,14 @@ public: @since LibreOffice 3.5 */ - sal_Char operator [](sal_Int32 index) const { return getStr()[index]; } + sal_Char 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 + return getStr()[index]; + } /** Compares two strings. diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 768f5521303d..0af8b6d548ac 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -474,7 +474,14 @@ public: @since LibreOffice 3.5 */ - sal_Unicode operator [](sal_Int32 index) const { return getStr()[index]; } + 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 + return getStr()[index]; + } /** Compares two strings. |