diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-06-14 12:24:41 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-09-22 21:54:37 +0200 |
commit | 26446c1061bc8ad1b125bd29e4a439931a4c1b68 (patch) | |
tree | 36ce7fb6a52dd25a87735a8b2230d0424afbf436 /sc | |
parent | 268d8cd47312df921ed05385a25966a75165cede (diff) |
crashtesting: negative index seen on loading forum-de3-15472.ods
Change-Id: I737e6132f117a85c4d7e5df4a33561d09eff86af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135837
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit d26e960fb3cb6dcff887654b3ec51e5cdea5a878)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 64c0d990c147..674ee87f2edf 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; |