Kaydet (Commit) d97bdf10 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 16bf916e
...@@ -946,15 +946,19 @@ bool ParseDouble( const sal_Unicode*& rp, double& rRet ) ...@@ -946,15 +946,19 @@ bool ParseDouble( const sal_Unicode*& rp, double& rRet )
rp = p; rp = p;
fInt += fFrac; fInt += fFrac;
sal_Int32 nLog10 = sal_Int32( log10( fInt ) );
if( bNegExp ) if (fInt != 0.0) // exact check; log10(0.0) may entail a pole error
nExp = -nExp; {
sal_Int32 nLog10 = sal_Int32( log10( fInt ) );
if( nLog10 + nExp > nMaxExp ) if( bNegExp )
return false; nExp = -nExp;
fInt = ::rtl::math::pow10Exp( fInt, nExp ); if( nLog10 + nExp > nMaxExp )
return false;
fInt = ::rtl::math::pow10Exp( fInt, nExp );
}
if( bNegNum ) if( bNegNum )
fInt = -fInt; fInt = -fInt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment