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

Avoid left shift of negative values (ubsan)

Change-Id: Ie4f6a4e3e54770c00741cc268ed9e27ecafac500
üst 1e5d17f8
...@@ -135,9 +135,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue ) ...@@ -135,9 +135,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue )
fFrac = modf( fValue, &fInt ); fFrac = modf( fValue, &fInt );
if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) ) // 2^29 if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) ) // 2^29
{ {
rnRKValue = static_cast< sal_Int32 >( fInt ); rnRKValue
rnRKValue <<= 2; = static_cast<sal_Int32>(
rnRKValue |= EXC_RK_INT; static_cast<sal_uInt32>(static_cast<sal_Int32>(fInt)) << 2)
| EXC_RK_INT;
return true; return true;
} }
...@@ -145,9 +146,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue ) ...@@ -145,9 +146,10 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue )
fFrac = modf( fValue * 100.0, &fInt ); fFrac = modf( fValue * 100.0, &fInt );
if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) ) if( (fFrac == 0.0) && (fInt >= -536870912.0) && (fInt <= 536870911.0) )
{ {
rnRKValue = static_cast< sal_Int32 >( fInt ); rnRKValue
rnRKValue <<= 2; = static_cast<sal_Int32>(
rnRKValue |= EXC_RK_INT100; static_cast<sal_uInt32>(static_cast<sal_Int32>(fInt)) << 2)
| EXC_RK_INT100;
return true; return true;
} }
......
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