diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-06-20 15:37:35 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 12:33:36 +0200 |
commit | cbe3b2fe0b9d745e22a2bf436ce55141b15f9502 (patch) | |
tree | 899722f2db90c470102608485f89b0ef71424ef7 /include/rtl/ustrbuf.hxx | |
parent | 1f832584f7cfa78d5b9c2de66d5133635f587ab0 (diff) |
Avoid conversion warning in O[U]String[Buffer] constructors
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, modifying the patch to
carefully keep the undefined behavior in the already existing additions that may
potentially overflow, instead of making the static_cast<sal_Int32> introduction
look like end - pData->buffer will be guaranteed to fit into sal_Int32 (which it
is not).
Change-Id: Id2fb64dc4585dae34257be6968a8905254a3b42d
Diffstat (limited to 'include/rtl/ustrbuf.hxx')
-rw-r--r-- | include/rtl/ustrbuf.hxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index abb85a087ce2..04ac8a6c00f4 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -181,7 +181,7 @@ public: pData = rtl_uString_alloc( nCapacity ); sal_Unicode* end = c.addData( pData->buffer ); *end = '\0'; - pData->length = end - pData->buffer; + pData->length = l; // TODO realloc in case pData->>length is noticeably smaller than l ? } #endif @@ -484,13 +484,14 @@ public: template< typename T1, typename T2 > OUStringBuffer& append( const OUStringConcat< T1, T2 >& c ) { - const int l = c.length(); + sal_Int32 l = c.length(); if( l == 0 ) return *this; - rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l ); + l += pData->length; + rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, l ); sal_Unicode* end = c.addData( pData->buffer + pData->length ); *end = '\0'; - pData->length = end - pData->buffer; + pData->length = l; return *this; } #endif |