Patch 0001
it seems to me that addData via the different addDataHelper, do _not_
add the final binary 0, like rtl_stringbuffer_insert() for instance is
doing
so:
+#ifdef RTL_FAST_STRING
+ template< typename T1, typename T2 >
+ OStringBuffer( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ rtl_String* buffer = NULL;
+ rtl_string_new_WithLength( &buffer, l );
+ char* end = c.addData( buffer->buffer );
^^^
here the buffer is not 0-terminated...
so
OStringBuffer sBuff
sBuff.append("foo")
printf("%s", sBuff.getStr()) -> ok
OStringBuffer sBuff = "f" + "oo";
printf("%s", sBuff.getStr()) -> segfault or at least buffer overrun
no?
vaguely related... since we are talking about performance... why
*_new_WithLength() in strtmpl.cxx is doing a memset on the whole newly
allocated buffer...
surely the allocated buffer will be filled with something soon
enough... all that is needed is buffer[0] = 0 to make getStr()
C-string-safe.
Norbert
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.