diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-12-03 17:36:21 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-12-03 18:04:25 +0100 |
commit | 13d277b5504a47ae2e2320685669b27b5ed3a3ba (patch) | |
tree | 1e1dd6b787a2103bdc5f408f731d915be4cabeaf /sal | |
parent | 371443a8045a8f777323472f9cb702f00084b0dc (diff) |
fix capacity in stringbuffers
rtl_stringbuffer_* functions silently allocate +16 extra for capacity,
but rtl_string_* functions do not. As intuitive and obvious as ever.
Change-Id: Ia0bb63dedf31f6ad5c687187221d7385043b5456
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/strbuf.hxx | 5 | ||||
-rw-r--r-- | sal/inc/rtl/ustrbuf.hxx | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 5efd0557430e..7a28298f4cea 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -229,11 +229,12 @@ public: { const int l = c.length(); rtl_String* buffer = NULL; - rtl_string_new_WithLength( &buffer, l ); + nCapacity = l + 16; + rtl_string_new_WithLength( &buffer, nCapacity ); char* end = c.addData( buffer->buffer ); + *end = '\0'; buffer->length = end - buffer->buffer; pData = buffer; - nCapacity = l + 16; } #endif diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index 06d906e864eb..5f133bfc9205 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -221,12 +221,13 @@ public: { const int l = c.length(); rtl_uString* buffer = NULL; - rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary + nCapacity = l + 16; + rtl_uString_new_WithLength( &buffer, nCapacity ); // TODO this clears, not necessary sal_Unicode* end = c.addData( buffer->buffer ); + *end = '\0'; buffer->length = end - buffer->buffer; // TODO realloc in case buffer->length is noticeably smaller than l ? pData = buffer; - nCapacity = l + 16; } #endif /** Assign to this a copy of value. |