Commit 65642f4b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Avoid depending on signed variable overflow in parse_double.

parent 9733b821
......@@ -549,8 +549,10 @@ static double strtod16(MSVCRT_wchar_t get(void *ctx), void unget(void *ctx),
}
if(nch>='0' && nch<='9') {
while(nch>='0' && nch<='9') {
if(e>INT_MAX/10 || (e=e*10+nch-'0')<0)
if(e>INT_MAX/10 || e*10>INT_MAX-nch+'0')
e = INT_MAX;
else
e = e*10+nch-'0';
nch = get(ctx);
}
if((nch!=MSVCRT_WEOF) && (nch < '0' || nch > '9')) unget(ctx);
......@@ -827,8 +829,10 @@ double parse_double(MSVCRT_wchar_t (*get)(void *ctx), void (*unget)(void *ctx),
if(nch>='0' && nch<='9') {
while(nch>='0' && nch<='9') {
if(e>INT_MAX/10 || (e=e*10+nch-'0')<0)
if(e>INT_MAX/10 || e*10>INT_MAX-nch+'0')
e = INT_MAX;
else
e = e*10+nch-'0';
nch = get(ctx);
}
if(nch != MSVCRT_WEOF) unget(ctx);
......
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