oleaut32: Fix possible integer overflow in VarR4FromDec.
This commit is contained in:
parent
33aa59abea
commit
7280762238
|
@ -2890,6 +2890,7 @@ static void test_VarR4FromDec(void)
|
|||
|
||||
CONVERT_DEC(VarR4FromDec,2,0x80,0,3276800); EXPECT(-32768.0f);
|
||||
CONVERT_DEC(VarR4FromDec,2,0,0,3276700); EXPECT(32767.0f);
|
||||
CONVERT_DEC(VarR4FromDec,10,0,0,3276700); EXPECT(0.00032767f);
|
||||
|
||||
CONVERT_DEC(VarR4FromDec,0,0,1,0); EXPECT(18446744073709551616.0f);
|
||||
}
|
||||
|
|
|
@ -2948,28 +2948,28 @@ HRESULT WINAPI VarR4FromUI4(ULONG ulIn, float *pFltOut)
|
|||
HRESULT WINAPI VarR4FromDec(DECIMAL* pDecIn, float *pFltOut)
|
||||
{
|
||||
BYTE scale = DEC_SCALE(pDecIn);
|
||||
int divisor = 1;
|
||||
double divisor = 1.0;
|
||||
double highPart;
|
||||
|
||||
if (scale > DEC_MAX_SCALE || DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
|
||||
return E_INVALIDARG;
|
||||
|
||||
while (scale--)
|
||||
divisor *= 10;
|
||||
divisor *= 10.0;
|
||||
|
||||
if (DEC_SIGN(pDecIn))
|
||||
divisor = -divisor;
|
||||
|
||||
if (DEC_HI32(pDecIn))
|
||||
{
|
||||
highPart = (double)DEC_HI32(pDecIn) / (double)divisor;
|
||||
highPart = (double)DEC_HI32(pDecIn) / divisor;
|
||||
highPart *= 4294967296.0F;
|
||||
highPart *= 4294967296.0F;
|
||||
}
|
||||
else
|
||||
highPart = 0.0;
|
||||
|
||||
*pFltOut = (double)DEC_LO64(pDecIn) / (double)divisor + highPart;
|
||||
*pFltOut = (double)DEC_LO64(pDecIn) / divisor + highPart;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue