summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-01-25 16:11:14 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-01-25 16:15:58 +0100
commitd97bdf10d2654851d69a726b659d68eba3d9076e (patch)
treefca181b901810275157df2b19619014c27708422 /scaddins
parent16bf916eee4148d66a13323aa69c1bb272c3219e (diff)
Avoid calling log10(0)
...to avoid UBSan reporting during CppunitTest_sc_addin_functions_test: [...] > Testing file:///data/sbergman/lo-san/core/sc/qa/unit/data/functions/addin/fods/imabs.fods: > warn:xmloff.style:14186:1:xmloff/source/style/xmlstyle.cxx:300: Here is a duplicate Style > scaddins/source/analysis/analysishelper.cxx:949:37: runtime error: value -inf is outside the range of representable values of type 'int' > #0 0x7f77717d11d6 in sca::analysis::ParseDouble(char16_t const*&, double&) scaddins/source/analysis/analysishelper.cxx:949:37 > #1 0x7f77717e39e5 in sca::analysis::Complex::ParseString(rtl::OUString const&, sca::analysis::Complex&) scaddins/source/analysis/analysishelper.cxx:1690:10 > #2 0x7f77717e317f in sca::analysis::Complex::Complex(rtl::OUString const&) scaddins/source/analysis/analysishelper.cxx:1664:10 > #3 0x7f777167fa79 in AnalysisAddIn::getImabs(rtl::OUString const&) scaddins/source/analysis/analysis.cxx:912:19 > #4 0x7f78148bd16a in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77:5 > #5 0x7f78148b6b70 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13 > #6 0x7f78148b3894 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(_uno_Interface*, _typelib_TypeDescription const*, void*, void**, _uno_Any**) bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:420:13 > #7 0x7f7772bdd096 in stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx:697:9 > #8 0x7f7772bdf45a in non-virtual thunk to stoc_corefl::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) stoc/source/corereflection/criface.cxx > #9 0x7f77d3c63f17 in ScUnoAddInCall::ExecuteCallWithArgs(com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) sc/source/core/tool/addincol.cxx:1466:31 > #10 0x7f77d3c631da in ScUnoAddInCall::ExecuteCall() sc/source/core/tool/addincol.cxx:1444:9 > #11 0x7f77d484504f in ScInterpreter::ScExternal() sc/source/core/tool/interpr4.cxx:2999:19 [...] Change-Id: Ie31d6374bdac3ae11784d925011c5a67802cdf56
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysishelper.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 5548c31a9f8a..d542c049d959 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -946,15 +946,19 @@ bool ParseDouble( const sal_Unicode*& rp, double& rRet )
rp = p;
fInt += fFrac;
- sal_Int32 nLog10 = sal_Int32( log10( fInt ) );
- if( bNegExp )
- nExp = -nExp;
+ if (fInt != 0.0) // exact check; log10(0.0) may entail a pole error
+ {
+ sal_Int32 nLog10 = sal_Int32( log10( fInt ) );
- if( nLog10 + nExp > nMaxExp )
- return false;
+ if( bNegExp )
+ nExp = -nExp;
- fInt = ::rtl::math::pow10Exp( fInt, nExp );
+ if( nLog10 + nExp > nMaxExp )
+ return false;
+
+ fInt = ::rtl::math::pow10Exp( fInt, nExp );
+ }
if( bNegNum )
fInt = -fInt;