use std::vector for fetching DX array data

because I'm trying to track down a related heap corruption, and that is
much easier if the access to the array is checked by the std::vector
debug runtime

Change-Id: Ia665f5cebb7f14d88942e88b4b400ad3c28ef5d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121527
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2021-09-02 20:05:09 +02:00
parent 86fa9c9073
commit d4dc6b5cfd
27 changed files with 235 additions and 257 deletions

View File

@@ -2567,15 +2567,15 @@ namespace cppcanvas::internal
// generating a DX array, and uniformly
// distributing the excess/insufficient width
// to every logical character.
std::unique_ptr< ::tools::Long []> pDXArray( new ::tools::Long[nLen] );
std::vector<::tools::Long> aDXArray;
rVDev.GetTextArray( pAct->GetText(), pDXArray.get(),
rVDev.GetTextArray( pAct->GetText(), &aDXArray,
pAct->GetIndex(), pAct->GetLen() );
const sal_Int32 nWidthDifference( pAct->GetWidth() - pDXArray[ nLen-1 ] );
const sal_Int32 nWidthDifference( pAct->GetWidth() - aDXArray[ nLen-1 ] );
// Last entry of pDXArray contains total width of the text
::tools::Long* p = pDXArray.get();
::tools::Long* p = aDXArray.data();
for (sal_Int32 i = 1; i <= nLen; ++i)
{
// calc ratio for every array entry, to
@@ -2592,7 +2592,7 @@ namespace cppcanvas::internal
sText,
pAct->GetIndex(),
nLen,
pDXArray.get(),
aDXArray.data(),
rFactoryParms,
bSubsettableActions );
}

View File

@@ -186,12 +186,11 @@ namespace cppcanvas::internal
{
// no external DX array given, create one from given
// string
std::unique_ptr< ::tools::Long []> pCharWidths( new ::tools::Long[nLen] );
std::vector<::tools::Long> aCharWidths;
rVDev.GetTextArray( rText, pCharWidths.get(),
nStartPos, nLen );
rVDev.GetTextArray( rText, &aCharWidths, nStartPos, nLen );
return setupDXArray( pCharWidths.get(), nLen, rState );
return setupDXArray( aCharWidths.data(), nLen, rState );
}
::basegfx::B2DPoint adaptStartPoint( const ::basegfx::B2DPoint& rStartPoint,