[Libreoffice-commits] core.git: chart2/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jun 15 07:27:35 UTC 2019
chart2/source/tools/PolynomialRegressionCurveCalculator.cxx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit 503de0ae62847959af5ea9d1f8621adc1f8126e7
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 14 22:18:57 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sat Jun 15 09:26:30 2019 +0200
Avoid -fsanitize=float-divide-by-zero
...when loading xls/tdf117254-4.xls as obtained by
bin/get-bugzilla-attachments-by-mimetype (i.e., the attachment at
<https://bugs.documentfoundation.org/show_bug.cgi?id=117254#c5>):
> chart2/source/tools/PolynomialRegressionCurveCalculator.cxx:189:32: runtime error: division by zero
> #0 in chart::PolynomialRegressionCurveCalculator::recalculateRegression(com::sun::star::uno::Sequence<double> const&, com::sun::star::uno::Sequence<double> const&) at chart2/source/tools/PolynomialRegressionCurveCalculator.cxx:189:32
> #1 in chart::VSeriesPlotter::createRegressionCurvesShapes(chart::VDataSeries const&, com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> const&, com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> const&, bool) at chart2/source/view/charttypes/VSeriesPlotter.cxx:1343:22
> #2 in chart::AreaChart::impl_createSeriesShapes() at chart2/source/view/charttypes/AreaChart.cxx:539:17
> #3 in chart::AreaChart::createShapes() at chart2/source/view/charttypes/AreaChart.cxx:965:5
> #4 in chart::ChartView::impl_createDiagramAndContent(chart::CreateShapeParam2D const&, com::sun::star::awt::Size const&) at chart2/source/view/main/ChartView.cxx:1608:25
> #5 in chart::ChartView::createShapes2D(com::sun::star::awt::Size const&) at chart2/source/view/main/ChartView.cxx:3037:41
> #6 in chart::ChartView::createShapes() at chart2/source/view/main/ChartView.cxx:2506:5
[...]
Leaving aRSquared initialized to 0.0 when the divisor is zero is in line with
the code prior to 00cb825ab3f16a94f1e8311ba0c24f72588e788e "fdo#75538 R^2
calculation for trendline similar to LINEST function" and with the recent nearby
change f44d14e5f3909a4271034ba02da92ed2dee7b89c "Avoid
-fsanitize=float-divide-by-zero".
Change-Id: If2c17ad178788982729f647b4c695d3788fad500
Reviewed-on: https://gerrit.libreoffice.org/74068
Tested-by: Jenkins
Reviewed-by: Laurent BP <laurent.balland-poirier at laposte.net>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index 530d0d4a16a5..b087fc52cede 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -186,7 +186,10 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
double aRSquared = 0.0;
if(mForceIntercept)
{
- aRSquared = aSumYpred2 / (aSumError + aSumYpred2);
+ if (auto const div = aSumError + aSumYpred2)
+ {
+ aRSquared = aSumYpred2 / div;
+ }
}
else if (aSumTotal != 0.0)
{
More information about the Libreoffice-commits
mailing list