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>
This commit is contained in:
Stephan Bergmann
2019-10-17 09:03:53 +02:00
parent 7972ce0d6b
commit c8eaadb5d7
21 changed files with 91 additions and 222 deletions
+5 -11
View File
@@ -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;
}
+1 -5
View File
@@ -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 );
+3 -5
View File
@@ -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 );
}
}