From 8644d10098a10e02c426a4ae80ce179586f35089 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 3 Apr 2013 11:27:05 +0200 Subject: Asserting rtl::O[U]StringBuffer::operator [] preconditions ...and fixing two call-sites. Change-Id: I8ed8cb189bd5034130b49b2f57156568e6b24716 --- sal/inc/rtl/strbuf.hxx | 6 +++++- sal/inc/rtl/ustrbuf.hxx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sal/inc/rtl') 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 -- cgit