summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-02 20:05:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-04 08:17:06 +0200
commitd4dc6b5cfdb02ad00a06ad32650948648abe010d (patch)
tree02446cd93e68aba9b78db6eb7fc902e782c6faf9 /starmath
parent86fa9c907387e96c9c93f1e17239730271fedbfd (diff)
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>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/accessibility.cxx16
1 files changed, 7 insertions, 9 deletions
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index b66ba5c9c276..3bb9d1196482 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -487,12 +487,11 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
OutputDevice& rDevice = pDrawingArea->get_ref_device();
- std::unique_ptr<tools::Long[]> pXAry(new tools::Long[ aNodeText.getLength() ]);
+ std::vector<tools::Long> aXAry;
rDevice.SetFont( pNode->GetFont() );
- rDevice.GetTextArray( aNodeText, pXAry.get(), 0, aNodeText.getLength() );
- aTLPos.AdjustX(nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0 );
- aSize.setWidth( nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex] );
- pXAry.reset();
+ rDevice.GetTextArray( aNodeText, &aXAry, 0, aNodeText.getLength() );
+ aTLPos.AdjustX(nNodeIndex > 0 ? aXAry[nNodeIndex - 1] : 0 );
+ aSize.setWidth( nNodeIndex > 0 ? aXAry[nNodeIndex] - aXAry[nNodeIndex - 1] : aXAry[nNodeIndex] );
aTLPos = rDevice.LogicToPixel( aTLPos );
aSize = rDevice.LogicToPixel( aSize );
@@ -560,15 +559,14 @@ sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoin
tools::Long nNodeX = pNode->GetLeft();
- std::unique_ptr<tools::Long[]> pXAry(new tools::Long[ aTxt.getLength() ]);
+ std::vector<tools::Long> aXAry;
rDevice.SetFont( pNode->GetFont() );
- rDevice.GetTextArray( aTxt, pXAry.get(), 0, aTxt.getLength() );
+ rDevice.GetTextArray( aTxt, &aXAry, 0, aTxt.getLength() );
for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
{
- if (pXAry[i] + nNodeX > aPos.X())
+ if (aXAry[i] + nNodeX > aPos.X())
nRes = i;
}
- pXAry.reset();
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
"invalid accessible index" );