From 0d4c1cc6ea39404c4ad1c8abe0d70dabcac1e017 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Caol=C3=A1n=20McNamara?= Date: Sun, 7 Nov 2021 15:17:22 +0000 Subject: [PATCH] use a std::vector MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I186f34025863882951aaa70f94ea21b8ac556dab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124821 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- filter/source/msfilter/svdfppt.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index ba2bc383f6bd..a4f469967bb5 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -5253,16 +5253,17 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe if( aTextHd.nRecType == PPT_PST_TextCharsAtom ) { - sal_uInt32 i; - sal_Unicode nChar; - std::unique_ptr pBuf(new sal_Unicode[ ( nMaxLen >> 1 ) + 1 ]); - void* pDest = pBuf.get(); + std::vector aBuf(( nMaxLen >> 1 ) + 1); + void* pDest = aBuf.data(); auto nRead = rIn.ReadBytes(pDest, nMaxLen); if (nRead != nMaxLen) memset(static_cast(pDest) + nRead, 0, nMaxLen - nRead); nMaxLen >>= 1; - pBuf[ nMaxLen ] = 0; - sal_Unicode* pPtr = pBuf.get(); + aBuf[nMaxLen] = 0; + + sal_uInt32 i; + sal_Unicode* pPtr = aBuf.data(); + #ifdef OSL_BIGENDIAN sal_Unicode nTemp; for ( i = 0; i < nMaxLen; i++ ) @@ -5270,12 +5271,12 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe nTemp = *pPtr; *pPtr++ = ( nTemp << 8 ) | ( nTemp >> 8 ); } - pPtr = pBuf.get(); + pPtr = aBuf.data(); #endif for ( i = 0; i < nMaxLen; pPtr++, i++ ) { - nChar = *pPtr; + sal_Unicode nChar = *pPtr; if ( !nChar ) break; if ( ( nChar & 0xff00 ) == 0xf000 ) // in this special case we got a symbol @@ -5289,7 +5290,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe } } if ( i ) - aString = OUString(pBuf.get(), i); + aString = OUString(aBuf.data(), i); } else if( aTextHd.nRecType == PPT_PST_TextBytesAtom ) { -- 2.11.4.GIT