diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-06-14 17:38:31 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-06-14 22:02:35 +0200 |
commit | 3a53860fd0d345c288659a32b7438d6eebd921e0 (patch) | |
tree | db83f397d2fb8c4e776c4fdd1dd05726beba118f | |
parent | cd356b29a3c739938ff29cfb19773e9d2fcd07f4 (diff) |
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@redhat.com>
-rw-r--r-- | chart2/source/tools/PolynomialRegressionCurveCalculator.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
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++) { |