oleaut32: Fix the overflow check in VarNumFromParseNum.

Spotted by Adam Martinson.
This commit is contained in:
Alexandre Julliard 2010-11-17 13:42:50 +01:00
parent 5d7aac8c38
commit 4e94fd5567
2 changed files with 4 additions and 2 deletions

View File

@ -2592,7 +2592,9 @@ static void test_VarUI8FromStr(void)
CONVERT_STR(VarUI8FromStr,"0",0); EXPECTI8(0);
CONVERT_STR(VarUI8FromStr,"-1",0); EXPECT_OVERFLOW;
CONVERT_STR(VarUI8FromStr,"2147483647",0); EXPECTI8(2147483647);
CONVERT_STR(VarUI8FromStr,"18446744073709551615",0); todo_wine EXPECTI864(0xFFFFFFFF,0xFFFFFFFF);
CONVERT_STR(VarUI8FromStr,"18446744073709551614",0); EXPECTI864(0xFFFFFFFF,0xFFFFFFFE);
CONVERT_STR(VarUI8FromStr,"18446744073709551615",0); EXPECTI864(0xFFFFFFFF,0xFFFFFFFF);
CONVERT_STR(VarUI8FromStr,"18446744073709551616",0); EXPECT_OVERFLOW;
CONVERT_STR(VarUI8FromStr,"-1.5",LOCALE_NOUSEROVERRIDE); EXPECT_OVERFLOW;
CONVERT_STR(VarUI8FromStr,"-0.6",LOCALE_NOUSEROVERRIDE); EXPECT_OVERFLOW;

View File

@ -2186,7 +2186,7 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig,
/* Convert the integer part of the number into a UI8 */
for (i = 0; i < wholeNumberDigits; i++)
{
if (ul64 > (UI8_MAX / 10 - rgbDig[i]))
if (ul64 > UI8_MAX / 10 || (ul64 == UI8_MAX / 10 && rgbDig[i] > UI8_MAX % 10))
{
TRACE("Overflow multiplying digits\n");
bOverflow = TRUE;