diff options
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/string.hxx | 7 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 9 | ||||
-rw-r--r-- | sal/qa/rtl/strings/test_ostring_concat.cxx | 1 | ||||
-rw-r--r-- | sal/qa/rtl/strings/test_oustring_concat.cxx | 1 |
4 files changed, 13 insertions, 5 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 2c7a43dba897..aeb752890d1f 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -262,8 +262,11 @@ public: const int l = c.length(); rtl_String* buffer = NULL; rtl_string_new_WithLength( &buffer, l ); - char* end = c.addData( buffer->buffer ); - buffer->length = end - buffer->buffer; + if (l != 0) + { + char* end = c.addData( buffer->buffer ); + buffer->length = end - buffer->buffer; + } pData = buffer; } #endif diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 534bd889f05a..ec9f90ecd46f 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -330,9 +330,12 @@ public: const int l = c.length(); rtl_uString* buffer = NULL; rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary - sal_Unicode* end = c.addData( buffer->buffer ); - buffer->length = end - buffer->buffer; - // TODO realloc in case buffer->length is noticeably smaller than l ? + if (l != 0) + { + sal_Unicode* end = c.addData( buffer->buffer ); + buffer->length = end - buffer->buffer; + // TODO realloc in case buffer->length is noticeably smaller than l? + } pData = buffer; } #endif diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx index a79b2dad32fb..46457ddf5f35 100644 --- a/sal/qa/rtl/strings/test_ostring_concat.cxx +++ b/sal/qa/rtl/strings/test_ostring_concat.cxx @@ -47,6 +47,7 @@ CPPUNIT_TEST_SUITE_END(); void test::ostring::StringConcat::check() { // All the extra () are to protect commas againsts being treated as separators of macro arguments. + CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) ); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + OString( "bar" ))); TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, OString > )), typeid( OString( "foo" ) + OString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + "bar" )); diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx index 0cc25128a075..4f650dcf3657 100644 --- a/sal/qa/rtl/strings/test_oustring_concat.cxx +++ b/sal/qa/rtl/strings/test_oustring_concat.cxx @@ -47,6 +47,7 @@ CPPUNIT_TEST_SUITE_END(); void test::oustring::StringConcat::check() { // All the extra () are to protect commas againsts being treated as separators of macro arguments. + CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) ); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + OUString( "bar" ))); TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "foo" ) + OUString( "bar" ))); CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + "bar" )); |