diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2017-01-15 15:14:15 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-01-24 00:26:58 +0000 |
commit | 6db82982d65b2b15aa7cc2aab5e6219f2db15dd7 (patch) | |
tree | 01101a29ed9b0a68dcd6e2d037ae3c806f540349 /sc/source | |
parent | f3bc969dd5bb4a45946728806159e658056a2bca (diff) |
tdf#105348 add check for divide by zero situation.
Reviewed-on: https://gerrit.libreoffice.org/33098
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 84e87423c182ec78aba4eb108355906a0d2f0096)
Backported, without test case document.
Change-Id: I339997870a7983d829a8909d2b3da7b3ab03f58d
Reviewed-on: https://gerrit.libreoffice.org/33484
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index c9e145d46d06..77767f84356b 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -2695,8 +2695,14 @@ void ScInterpreter::ScTTest() PushNoValue(); return; } - fT = sqrt(fCount-1.0) * fabs(fSum1 - fSum2) / - sqrt(fCount * fSumSqrD - (fSum1-fSum2)*(fSum1-fSum2)); + double fSumD = fSum1 - fSum2; + double fDivider = (fCount*fSumSqrD - fSumD*fSumD); + if ( fDivider == 0.0 ) + { + PushError(FormulaError::DivisionByZero); + return; + } + fT = fabs(fSumD) * sqrt((fCount-1.0) / fDivider); fF = fCount - 1.0; } else if (fTyp == 2.0) |