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:⭐:uno::Sequence<double> const&, com::sun:⭐:uno::Sequence<double> const&) at chart2/source/tools/PolynomialRegressionCurveCalculator.cxx:189:32 > #1 in chart::VSeriesPlotter::createRegressionCurvesShapes(chart::VDataSeries const&, com::sun:⭐:uno::Reference<com::sun:⭐:drawing::XShapes> const&, com::sun:⭐:uno::Reference<com::sun:⭐: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:⭐:awt::Size const&) at chart2/source/view/main/ChartView.cxx:1608:25 > #5 in chart::ChartView::createShapes2D(com::sun:⭐: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 to00cb825ab3
"fdo#75538 R^2 calculation for trendline similar to LINEST function" and with the recent nearby changef44d14e5f3
"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@laposte.net> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
c872abf8e7
commit
503de0ae62
1 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue