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

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


 chart2/source/tools/PolynomialRegressionCurveCalculator.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 3a53860fd0d345c288659a32b7438d6eebd921e0
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 14 17:38:31 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Jun 14 22:02:35 2019 +0200

    Avoid -fsanitize=float-divide-by-zero
    
    ...as happens with `--convert-to pdf xls/rhbz499466-2.xls` with
    xls/rhbz499466-2.xls as obtained by bin/get-bugzilla-attachments-by-mimetype
    (i.e., the attachment at
    <https://bugzilla.redhat.com/show_bug.cgi?id=499466#c1>):
    
    > chart2/source/tools/PolynomialRegressionCurveCalculator.cxx:73:14: 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:73:14
    >  #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
    [...]
    
    Change-Id: I1ef70aa90256a5fcc84151d869d8ffc6acfbbb0e
    Reviewed-on: https://gerrit.libreoffice.org/74055
    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 050343c1dcc6..530d0d4a16a5 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -70,7 +70,10 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
         yVector[i] = yValue;
         yAverage += yValue;
     }
-    yAverage /= aNoValues;
+    if (aNoValues != 0)
+    {
+        yAverage /= aNoValues;
+    }
 
     for(sal_Int32 j = 0; j < aNoPowers; j++)
     {


More information about the Libreoffice-commits mailing list