summaryrefslogtreecommitdiff
path: root/cppu
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-16 22:53:34 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-17 09:03:53 +0200
commitc8eaadb5d70f42723517bb028f363e37726be256 (patch)
tree6d91ba30db1dde2c0ad00f0bd453bed937d98660 /cppu
parent7972ce0d6bc22a36d7fbaaa19bed11ec4cfe52d7 (diff)
Remaining loplugin:bufferadd
...that had been missing because the plugin didn't implement postRun, so it didn't report anything when run as part of the shared plugin. (But did report the expected warnings when run as a standalone plugin during CompilerTest_compilerplugins_clang.) Most fixes are straightforward. A noteworthy one is PreparedStatement::setBytes in connectivity/source/drivers/postgresql/pq_preparedstatement.cxx: The old preallocation of a 20 character OStringBuffer might have prevented buf.append( reinterpret_cast<char *>(escapedString), len -1 ); from potentially throwing std::bad_alloc, which would have caused escapedString to be leaked. Even though that 20-character preallocation was likely just random junk and not meant to address the potential leak, lets address it now. Change-Id: Ib506332d061684a22a74e5e39e591539fd2c4900 Reviewed-on: https://gerrit.libreoffice.org/80925 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'cppu')
-rw-r--r--cppu/source/cppu/cppu_opt.cxx16
-rw-r--r--cppu/source/typelib/static_types.cxx6
-rw-r--r--cppu/source/uno/lbenv.cxx8
3 files changed, 9 insertions, 21 deletions
diff --git a/cppu/source/cppu/cppu_opt.cxx b/cppu/source/cppu/cppu_opt.cxx
index 9ad9fbd98f0f..40f90de6e347 100644
--- a/cppu/source/cppu/cppu_opt.cxx
+++ b/cppu/source/cppu/cppu_opt.cxx
@@ -22,7 +22,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <typelib/typedescription.h>
#include <uno/any2.h>
-#include <rtl/ustrbuf.hxx>
+#include <rtl/ustring.hxx>
using namespace ::rtl;
@@ -32,11 +32,8 @@ extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iquery_msg(
typelib_TypeDescriptionReference * pType )
SAL_THROW_EXTERN_C()
{
- OUStringBuffer buf( 64 );
- buf.append( "unsatisfied query for interface of type " );
- buf.append( OUString::unacquired( &pType->pTypeName ) );
- buf.append( '!' );
- OUString ret( buf.makeStringAndClear() );
+ OUString ret = "unsatisfied query for interface of type "
+ + OUString::unacquired( &pType->pTypeName ) + "!";
rtl_uString_acquire( ret.pData );
return ret.pData;
}
@@ -46,11 +43,8 @@ extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iset_msg(
typelib_TypeDescriptionReference * pType )
SAL_THROW_EXTERN_C()
{
- OUStringBuffer buf( 64 );
- buf.append( "invalid attempt to assign an empty interface of type " );
- buf.append( OUString::unacquired( &pType->pTypeName ) );
- buf.append( '!' );
- OUString ret( buf.makeStringAndClear() );
+ OUString ret = "invalid attempt to assign an empty interface of type "
+ + OUString::unacquired( &pType->pTypeName ) + "!";
rtl_uString_acquire( ret.pData );
return ret.pData;
}
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index f88e642aeb7b..5a400817115d 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -24,7 +24,6 @@
#include <osl/mutex.hxx>
#include <rtl/ustring.hxx>
-#include <rtl/ustrbuf.hxx>
#include <rtl/instance.hxx>
#include <typelib/typedescription.h>
@@ -297,10 +296,7 @@ void SAL_CALL typelib_static_sequence_type_init(
MutexGuard aGuard( typelib_StaticInitMutex::get() );
if (! *ppRef)
{
- OUStringBuffer aBuf( 32 );
- aBuf.append( "[]" );
- aBuf.append( pElementType->pTypeName );
- OUString aTypeName( aBuf.makeStringAndClear() );
+ OUString aTypeName = "[]" + OUString::unacquired(&pElementType->pTypeName);
assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) );
*ppRef = igetTypeByName( aTypeName.pData );
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
index fd1464d5244f..10995e7ad3e0 100644
--- a/cppu/source/uno/lbenv.cxx
+++ b/cppu/source/uno/lbenv.cxx
@@ -774,11 +774,9 @@ extern "C" void SAL_CALL uno_dumpEnvironmentByName(
}
else
{
- OUStringBuffer buf( 32 );
- buf.append( "environment \"" );
- buf.append( pEnvDcp );
- buf.append( "\" does not exist!" );
- writeLine( stream, buf.makeStringAndClear(), pFilter );
+ writeLine(
+ stream, "environment \"" + OUString::unacquired(&pEnvDcp) + "\" does not exist!",
+ pFilter );
}
}