sc/source/core/data/colorscale.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
New commits: commit c599c26967db0cd606c3ce9e7ee0153a65be28bb Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 14 12:24:41 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Jun 15 06:27:35 2022 +0200 crashtesting: negative index seen on loading forum-de3-15472.ods Change-Id: I737e6132f117a85c4d7e5df4a33561d09eff86af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135836 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index ee8bf407ba0e..96aeef2819c1 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -541,8 +541,10 @@ Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, co double GetPercentile( const std::vector<double>& rArray, double fPercentile ) { size_t nSize = rArray.size(); - size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1))); - double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1)); + double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1)); + SAL_WARN_IF(fFloor < 0, "sc", "negative percentile"); + size_t nIndex = fFloor >= 0 ? static_cast<size_t>(fFloor) : 0; + double fDiff = fPercentile * (nSize-1) - fFloor; std::vector<double>::const_iterator iter = rArray.begin() + nIndex; if (fDiff == 0.0) return *iter;