sal/rtl/strtmpl.hxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
New commits: commit 2c08104e4211594d3d06b1e4e85038276b58918a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Feb 23 07:28:17 2022 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Feb 23 08:07:36 2022 +0100 Use rtl::isAscii Change-Id: Iab88c3281f3dd1ba1668b3372420c97087c14da5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130381 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx index 856fce560065..d0f8fbeb6d83 100644 --- a/sal/rtl/strtmpl.hxx +++ b/sal/rtl/strtmpl.hxx @@ -1210,7 +1210,7 @@ void newFromLiteral ( IMPL_RTL_STRINGDATA** ppThi { if constexpr (sizeof(STRCODE<IMPL_RTL_STRINGDATA>) == sizeof(sal_Unicode)) { - assert(static_cast<unsigned char>(*pCharStr) < 0x80); // ASCII range + assert(rtl::isAscii(static_cast<unsigned char>(*pCharStr))); } SAL_WARN_IF( (static_cast<unsigned char>(*pCharStr)) == '\0', "rtl.string", "rtl_uString_newFromLiteral - Found embedded \\0 character" ); commit 8dcda24026d6d803f064351b1a1df8f6b77c2fa0 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Feb 23 07:15:44 2022 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Feb 23 08:07:21 2022 +0100 Simplify NewCopy a bit; avoid direct use of memcpy Change-Id: I197978604d0dfa997c95b907715ce891211621f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130380 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx index eec7010117d8..856fce560065 100644 --- a/sal/rtl/strtmpl.hxx +++ b/sal/rtl/strtmpl.hxx @@ -1001,18 +1001,17 @@ auto* NewCopy ( IMPL_RTL_STRINGDATA IMPL_RTL_STRINGDATA* pStr, sal_Int32 nCount ) { - assert(nCount >= 0); - IMPL_RTL_STRINGDATA* pData = Alloc<IMPL_RTL_STRINGDATA>( pStr->length ); - OSL_ASSERT(pData != nullptr); - - auto* pDest = pData->buffer; - auto* pSrc = pStr->buffer; + assert(ppThis); + assert(pStr); + assert(nCount >= 0 && nCount <= pStr->length); + *ppThis = Alloc<IMPL_RTL_STRINGDATA>( pStr->length ); + OSL_ASSERT(*ppThis != nullptr); - memcpy( pDest, pSrc, nCount * sizeof(*pSrc) ); + auto* pDest = (*ppThis)->buffer; - *ppThis = pData; + Copy(pDest, pStr->buffer, nCount); - RTL_LOG_STRING_NEW( pData ); + RTL_LOG_STRING_NEW( *ppThis ); return pDest + nCount; }