Piotr Caban : msvcrt: Fix overflow checks in parse_double.

Alexandre Julliard julliard at winehq.org
Tue Apr 28 16:32:22 CDT 2020


Module: wine
Branch: master
Commit: 405c99ef52d00ad032dcd672f7d08c52504aa0f5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=405c99ef52d00ad032dcd672f7d08c52504aa0f5

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Apr 28 19:21:40 2020 +0200

msvcrt: Fix overflow checks in parse_double.

Old check is optimized out in gcc 9.3.0 when -O2 optimization is
enabled.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/string.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 8183feacc0..9d122872d0 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -555,8 +555,8 @@ static double strtod16(MSVCRT_wchar_t get(void *ctx), void unget(void *ctx),
             if((nch!=MSVCRT_WEOF) && (nch < '0' || nch > '9')) unget(ctx);
             e *= s;
 
-            if(exp<0 && e<0 && exp+e>=0) exp = INT_MIN;
-            else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
+            if(e<0 && exp<INT_MIN-e) exp = INT_MIN;
+            else if(e>0 && exp>INT_MAX-e) exp = INT_MAX;
             else exp += e;
         } else {
             if(nch != MSVCRT_WEOF) unget(ctx);
@@ -784,8 +784,8 @@ double parse_double(MSVCRT_wchar_t (*get)(void *ctx), void (*unget)(void *ctx),
             if(nch != MSVCRT_WEOF) unget(ctx);
             e *= s;
 
-            if(exp<0 && e<0 && exp+e>=0) exp = INT_MIN;
-            else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
+            if(e<0 && exp<INT_MIN-e) exp = INT_MIN;
+            else if(e>0 && exp>INT_MAX-e) exp = INT_MAX;
             else exp += e;
         } else {
             if(nch != MSVCRT_WEOF) unget(ctx);




More information about the wine-cvs mailing list