sc/source/ui/inc/SparklineRenderer.hxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
New commits: commit 697a1bd99bf01a57f8dcf198d251010094347e87 Author: Andras Timar <[email protected]> AuthorDate: Sun Mar 1 18:04:18 2026 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Mar 3 09:36:51 2026 +0100 Fix SIGFPE in sparkline rendering with degenerate data When all sparkline values are equal (nMax == nMin), nDelta is 0 and the divisions (nValue - nMin) / nDelta produce Inf/NaN coordinates. Similarly, a line sparkline with only 1 data point divides by numberOfSteps = 0. These garbage coordinates propagate into VCL drawing functions where internal integer coordinate arithmetic triggers SIGFPE (FPE_INTDIV). Return early from drawLine() and drawColumn() when the data is degenerate (nDelta == 0, or too few values for a line chart). Change-Id: I69afedb117ea804749210ff46baaa9564513142a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200723 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/source/ui/inc/SparklineRenderer.hxx b/sc/source/ui/inc/SparklineRenderer.hxx index 9d304b1b2eb2..785dbea21c27 100644 --- a/sc/source/ui/inc/SparklineRenderer.hxx +++ b/sc/source/ui/inc/SparklineRenderer.hxx @@ -268,11 +268,17 @@ private: nMin = *rAttributes.getManualMin(); std::vector<SparklineValue> const& rValueList = rSparklineValues.getValuesList(); + if (rValueList.size() <= 1) + return; + + double nDelta = nMax - nMin; + if (nDelta == 0) + return; + std::vector<basegfx::B2DPolygon> aPolygons; aPolygons.emplace_back(); double numberOfSteps = rValueList.size() - 1; double xStep = 0; - double nDelta = nMax - nMin; std::vector<SparklineMarker> aMarkers; size_t nValueIndex = 0; @@ -414,6 +420,12 @@ private: nMin = *rAttributes.getManualMin(); std::vector<SparklineValue> const& rValueList = rSparklineValues.getValuesList(); + if (rValueList.empty()) + return; + + double nDelta = nMax - nMin; + if (nDelta == 0) + return; basegfx::B2DPolygon aPolygon; basegfx::B2DHomMatrix aMatrix; @@ -421,7 +433,6 @@ private: double xStep = 0; double numberOfSteps = rValueList.size(); - double nDelta = nMax - nMin; double nColumnSize = rRectangle.GetWidth() / numberOfSteps; nColumnSize = nColumnSize - (nColumnSize * 0.3);
