diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-10-23 15:27:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-10-23 15:27:37 +0200 |
commit | 413210a5036486dc1777565c3c69b2eda68b3f93 (patch) | |
tree | 52a8d4cf048d420754c1ac7137a3a6fde02a3fe0 /sc/source/filter | |
parent | 1e5d17f821783d0e4a2db92bb09eaff1eadc485a (diff) |
Avoid left shift of negative values (ubsan)
Change-Id: Ie4f6a4e3e54770c00741cc268ed9e27ecafac500
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/excel/xltools.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index 38b6dd07bed9..3c6d0f27e34f 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -135,9 +135,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue ) fFrac = modf( fValue, &fInt ); if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) ) // 2^29 { - rnRKValue = static_cast< sal_Int32 >( fInt ); - rnRKValue <<= 2; - rnRKValue |= EXC_RK_INT; + rnRKValue + = static_cast<sal_Int32>( + static_cast<sal_uInt32>(static_cast<sal_Int32>(fInt)) << 2) + | EXC_RK_INT; return true; } @@ -145,9 +146,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue ) fFrac = modf( fValue * 100.0, &fInt ); if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) ) { - rnRKValue = static_cast< sal_Int32 >( fInt ); - rnRKValue <<= 2; - rnRKValue |= EXC_RK_INT100; + rnRKValue + = static_cast<sal_Int32>( + static_cast<sal_uInt32>(static_cast<sal_Int32>(fInt)) << 2) + | EXC_RK_INT100; return true; } |