diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-28 09:27:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-29 12:38:51 +0200 |
commit | 894b4911ffb96ff667fdeb3aec7922316ab7230a (patch) | |
tree | 3942ed8088c058b70bb79984b186c5156284abf4 /emfio/source/reader/wmfreader.cxx | |
parent | 5b0ae3b59cd2cccfb72d991657366eb2a69bff49 (diff) |
pass DX array around using o3tl::span instead of pointer
so we get bounds checking in debug mode
Note that I cannot just pass around the std::vectors
involved because there is a place in editeng which
calls with a subset of a vector.
Change-Id: I5088a139593c27bf9cbe5d843ab4b0048ac6d508
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124330
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'emfio/source/reader/wmfreader.cxx')
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 62c5168a6bf0..9a04cdeb9823 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -721,7 +721,8 @@ namespace emfio IntersectClipRect( aRect ); } SAL_INFO( "emfio", "\t\t\t Text : " << aText ); - std::unique_ptr<tools::Long[]> pDXAry, pDYAry; + std::vector<tools::Long> aDXAry; + std::unique_ptr<tools::Long[]> pDYAry; auto nDxArySize = nMaxStreamPos - mpInputStream->Tell(); auto nDxAryEntries = nDxArySize >> 1; bool bUseDXAry = false; @@ -729,7 +730,7 @@ namespace emfio if ( ( ( nDxAryEntries % nOriginalTextLen ) == 0 ) && ( nNewTextLen <= nOriginalTextLen ) ) { sal_Int32 i; // needed just outside the for - pDXAry.reset(new tools::Long[ nNewTextLen ]); + aDXAry.resize( nNewTextLen ); if ( nOptions & ETO_PDY ) { pDYAry.reset(new tools::Long[ nNewTextLen ]); @@ -767,7 +768,7 @@ namespace emfio } } - pDXAry[ i ] = nDx; + aDXAry[ i ] = nDx; if ( nOptions & ETO_PDY ) { pDYAry[i] = nDy; @@ -776,8 +777,8 @@ namespace emfio if ( i == nNewTextLen ) bUseDXAry = true; } - if ( pDXAry && bUseDXAry ) - DrawText( aPosition, aText, pDXAry.get(), pDYAry.get() ); + if ( bUseDXAry ) + DrawText( aPosition, aText, &aDXAry, pDYAry.get() ); else DrawText( aPosition, aText ); if ( nOptions & ETO_CLIPPED ) @@ -1256,7 +1257,7 @@ namespace emfio { Point aPt; sal_uInt32 nStringLen, nDXCount; - std::unique_ptr<tools::Long[]> pDXAry; + std::vector<tools::Long> aDXAry; SvMemoryStream aMemoryStream( nEscLen ); aMemoryStream.WriteBytes(pData.get(), nEscLen); aMemoryStream.Seek( STREAM_SEEK_TO_BEGIN ); @@ -1274,15 +1275,15 @@ namespace emfio if ( ( static_cast< sal_uInt64 >( nDXCount ) * sizeof( sal_Int32 ) ) >= ( nEscLen - aMemoryStream.Tell() ) ) nDXCount = 0; if ( nDXCount ) - pDXAry.reset(new tools::Long[ nDXCount ]); + aDXAry.resize(nDXCount); for (sal_uInt32 i = 0; i < nDXCount; i++ ) { sal_Int32 val; aMemoryStream.ReadInt32( val); - pDXAry[ i ] = val; + aDXAry[ i ] = val; } aMemoryStream.ReadUInt32(mnSkipActions); - DrawText( aPt, aString, pDXAry.get() ); + DrawText( aPt, aString, aDXAry.empty() ? nullptr : &aDXAry ); } } } |