diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-26 20:55:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-27 11:52:26 +0000 |
commit | 1371ba2bcbcce57ba5cbd7a199ae8feceb22d0d0 (patch) | |
tree | b259d21c42e23e4c10235af6e6aaa05c0aa5abbf | |
parent | 4499db6b901a0c4eaad652a3efb5ad2857523c02 (diff) |
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 <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
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)"); |