From a6066989f7d346d0d43f8db46b12786546f769e8 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 15 Apr 2021 08:42:09 +0200 Subject: [PATCH] tdf#141689 Fix crash in 'Central' moving avg function Change-Id: I2dc5e517d5e3ff6283c9ff66c9f32ee95d66ef45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114121 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- .../source/tools/MovingAverageRegressionCurveCalculator.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx index 5496f78577e6..1c456b8835e6 100644 --- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx +++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx @@ -145,9 +145,10 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalc const uno::Reference< chart2::XScaling >& /*xScalingY*/, sal_Bool /*bMaySkipPointsInCalculation*/ ) { - uno::Sequence< geometry::RealPoint2D > aResult( aYList.size() ); + size_t nSize = std::min(aXList.size(), aYList.size()); + uno::Sequence< geometry::RealPoint2D > aResult( nSize ); - for( size_t i = 0; i < aYList.size(); ++i ) + for( size_t i = 0; i < nSize; ++i ) { aResult[i].X = aXList[i]; aResult[i].Y = aYList[i];