[Libreoffice-commits] core.git: chart2/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 14 14:48:48 UTC 2019


 chart2/source/tools/PolynomialRegressionCurveCalculator.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f44d14e5f3909a4271034ba02da92ed2dee7b89c
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 14 13:23:50 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Jun 14 16:47:41 2019 +0200

    Avoid -fsanitize=float-divide-by-zero
    
    ...as happens with `--convert-to pdf xls/fdo53482-2.xls` with xls/fdo53482-2.xls
    as obtained by xls/fdo53482-2.xls (i.e., the attachment at
    <https://bugs.documentfoundation.org/show_bug.cgi?id=53482#c25>):
    
    > chart2/source/tools/PolynomialRegressionCurveCalculator.cxx:190:38: 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:190:38
    >  #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:1341: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
    
    The division aSumError/aSumTotal is there ever since the code's introduction in
    e6a0cc2d6cb37bf4e04861173c7e55b307513778 "fdo#35712 polynomial and moving
    average regression lines", and quikee suggested this fix on IRC.
    
    Change-Id: Ic9cd7b8aaa8451e1230fca8137bad29e28f6477f
    Reviewed-on: https://gerrit.libreoffice.org/74036
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index 3727e38806ef..050343c1dcc6 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -185,7 +185,7 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
     {
         aRSquared = aSumYpred2 / (aSumError + aSumYpred2);
     }
-    else
+    else if (aSumTotal != 0.0)
     {
         aRSquared = 1.0 - (aSumError / aSumTotal);
     }


More information about the Libreoffice-commits mailing list