Daniel Lehman : msvcrt: Treat large exponent as overflow in strtod.

Alexandre Julliard julliard at winehq.org
Thu Jul 16 19:01:22 CDT 2020


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

Author: Daniel Lehman <dlehman25 at gmail.com>
Date:   Thu Jul 16 13:10:37 2020 +0200

msvcrt: Treat large exponent as overflow in strtod.

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

---

 dlls/msvcrt/string.c       | 2 +-
 dlls/msvcrt/tests/string.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 49cc8e40ae..a654bb1dde 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -423,7 +423,7 @@ static double make_double(int sign, int exp, ULONGLONG m, enum round round, int
         }
     }
 
-    if (exp >= 1<<EXP_BITS)
+    if (exp >= (1<<EXP_BITS)-1)
     {
         if (err) *err = MSVCRT_ERANGE;
         return sign * INFINITY;
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 8a2d678b63..ad41ad4d24 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -1956,7 +1956,12 @@ static void test__strtod(void)
         { "0.1d238", 7, 0.1e238 },
         { "0.1D-4736", 9, 0, ERANGE },
         { "3.4028234663852887e38", 21, FLT_MAX },
+        { "1.1754943508222875e-38", 22, FLT_MIN },
         { "1.7976931348623158e+308", 23, DBL_MAX },
+        { "1.7976931348623159e+308", 23, INFINITY, ERANGE },
+        { "2.2250738585072014e-308", 23, DBL_MIN },
+        { "-1.7976931348623158e+308", 24, -DBL_MAX },
+        { "-1.7976931348623159e+308", 24, -INFINITY, ERANGE },
         { "00", 2, 0 },
         { "00.", 3, 0 },
         { ".00", 3, 0 },




More information about the wine-cvs mailing list