From d4dc6b5cfdb02ad00a06ad32650948648abe010d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 2 Sep 2021 20:05:09 +0200 Subject: 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 --- emfio/source/reader/mtftools.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'emfio/source/reader') diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index aaefec7eb6e4..07143b8168af 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1869,6 +1869,7 @@ namespace emfio /* because text without dx array is badly scaled, we will create such an array if necessary */ tools::Long* pDX = pDXArry; + std::vector aMyDXArray; if (pDXArry) { // only useful when we have an imported DXArray @@ -1885,14 +1886,12 @@ namespace emfio // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading SolarMutexGuard aGuard; ScopedVclPtrInstance< VirtualDevice > pVDev; - pDX = new tools::Long[ rText.getLength() ]; pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); pVDev->SetFont( maLatestFont ); - pVDev->GetTextArray( rText, pDX, 0, rText.getLength()); + pVDev->GetTextArray( rText, &aMyDXArray, 0, rText.getLength()); + pDX = aMyDXArray.data(); } mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, rText.getLength() ) ); - if ( !pDXArry ) // this means we have created our own array - delete[] pDX; // which must be deleted } } SetGfxMode( nOldGfxMode ); -- cgit