Use known length to pre-initialize buffer
... and drop now-obsolete conditional include, which is included
unconditionally since commit 4c68c4b93c
Author Stephan Bergmann <sbergman@redhat.com>
Date Tue Mar 01 08:23:31 2022 +0100
misaligned-pointer-use
Change nCount argument to sal_Int32, since that's what is used for
string lengths. The call sites use sal_uInt16 and sal_uInt8 as the
argument value.
Change-Id: Ie2a9791f3ab9565590cb4f9c42d44f6eeff29745
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130754
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -24,15 +24,12 @@
|
||||
#include "WW8Sttbf.hxx"
|
||||
#include <osl/endian.h>
|
||||
#include <o3tl/make_shared.hxx>
|
||||
#include <o3tl/safeint.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
#include <sal/log.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
||||
#ifdef OSL_BIGENDIAN
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#endif
|
||||
|
||||
namespace ww8
|
||||
{
|
||||
WW8Struct::WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize)
|
||||
@@ -71,7 +68,7 @@ namespace ww8
|
||||
}
|
||||
|
||||
OUString WW8Struct::getUString(sal_uInt32 nOffset,
|
||||
sal_uInt32 nCount)
|
||||
sal_Int32 nCount)
|
||||
{
|
||||
OUString aResult;
|
||||
|
||||
@@ -82,10 +79,10 @@ namespace ww8
|
||||
if (nStartOff >= mn_size)
|
||||
return aResult;
|
||||
sal_uInt32 nAvailable = (mn_size - nStartOff)/sizeof(sal_Unicode);
|
||||
if (nCount > nAvailable)
|
||||
if (o3tl::make_unsigned(nCount) > nAvailable)
|
||||
nCount = nAvailable;
|
||||
OUStringBuffer aBuf;
|
||||
for (sal_uInt32 i = 0; i < nCount; ++i)
|
||||
OUStringBuffer aBuf(nCount);
|
||||
for (sal_Int32 i = 0; i < nCount; ++i)
|
||||
aBuf.append(static_cast<sal_Unicode>(getU16(nStartOff+i*2)));
|
||||
aResult = aBuf.makeStringAndClear();
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ namespace ww8
|
||||
sal_uInt16 getU16(sal_uInt32 nOffset)
|
||||
{ return getU8(nOffset) + (getU8(nOffset + 1) << 8); }
|
||||
|
||||
OUString getUString(sal_uInt32 nOffset, sal_uInt32 nCount);
|
||||
OUString getUString(sal_uInt32 nOffset, sal_Int32 nCount);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
Reference in New Issue
Block a user