diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-02-06 07:09:38 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-02-06 13:13:49 +0100 |
commit | 5bd55c22c1bd3e4daed48f9c162557dc9161d4ac (patch) | |
tree | 9df9069243f59756ef796ae513673fd42820cc24 /basic/source | |
parent | 05b067f05c561b1993deeea84a5700805bc9c3a6 (diff) |
We know the length here
Change-Id: I630b7fbda7c9ebf578e74260a0d67eea32e9e429
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129549
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/runtime/methods.cxx | 5 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 2 | ||||
-rw-r--r-- | basic/source/sbx/sbxstr.cxx | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index fd0c0531168c..7113e6e34f4c 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1610,8 +1610,9 @@ void SbRtl_Tab(StarBASIC *, SbxArray & rPar, bool) StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); else { - OUStringBuffer aStr; - comphelper::string::padToLength(aStr, rPar.Get(1)->GetLong(), '\t'); + const sal_Int32 nCount = std::max(rPar.Get(1)->GetLong(), sal_Int32(0)); + OUStringBuffer aStr(nCount); + comphelper::string::padToLength(aStr, nCount, '\t'); rPar.Get(0)->PutString(aStr.makeStringAndClear()); } } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index afc785e76b32..6cdc371d4147 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -4585,7 +4585,7 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3 if( bFixedString ) { sal_uInt16 nCount = static_cast<sal_uInt16>( nOp2 >> 17 ); // len = all bits above 0x10000 - OUStringBuffer aBuf; + OUStringBuffer aBuf(nCount); comphelper::string::padToLength(aBuf, nCount); pVar->PutString(aBuf.makeStringAndClear()); } diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx index 0c6fc19d514b..4e447bb600bb 100644 --- a/basic/source/sbx/sbxstr.cxx +++ b/basic/source/sbx/sbxstr.cxx @@ -302,7 +302,7 @@ SbxArray* StringToByteArray(const OUString& rStr) OUString ByteArrayToString(SbxArray* pArr) { sal_uInt32 nCount = pArr->Count(); - OUStringBuffer aStrBuf; + OUStringBuffer aStrBuf((nCount + 1) / 2); sal_Unicode aChar = 0; for( sal_uInt32 i = 0 ; i < nCount ; i++ ) { |