sc/source/core/tool/interpr3.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
New commits: commit d279c564a134160c5fc9b5ed6674aec58b8792a3 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jan 26 20:55:57 2023 +0000 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Feb 1 10:58:46 2023 +0000 crashtesting: crash on forum-mso-en4-719754.xlsx with fPercentile ~== 1 input is fPercentile of near 1 where approxFloor would give nIndex of nSize-1 resulting in a non-zero tiny negative fDiff, when the assumption is fDiff will be 0 or some positive value. Change-Id: I8fe5520f2b3c68f3204d435337df527185dcb0d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146218 Tested-by: Jenkins Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 1371ba2bcbcce57ba5cbd7a199ae8feceb22d0d0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146203 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index f55fc1636959..12e49de73972 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -3409,8 +3409,13 @@ double ScInterpreter::GetPercentile( vector<double> & rArray, double fPercentile OSL_ENSURE(nIndex < nSize, "GetPercentile: wrong index(1)"); vector<double>::iterator iter = rArray.begin() + nIndex; ::std::nth_element( rArray.begin(), iter, rArray.end()); - if (fDiff == 0.0) + if (fDiff <= 0.0) + { + // Note: neg fDiff seen with forum-mso-en4-719754.xlsx with + // fPercentile of near 1 where approxFloor gave nIndex of nSize-1 + // resulting in a non-zero tiny negative fDiff. return *iter; + } else { OSL_ENSURE(nIndex < nSize-1, "GetPercentile: wrong index(2)");