Piotr Caban : msvcrt: Don't detect overflow in atol implementation.

Alexandre Julliard julliard at winehq.org
Mon Mar 18 16:20:13 CDT 2019


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Sat Mar 16 14:49:08 2019 +0100

msvcrt: Don't detect overflow in atol implementation.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46845
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/string.c       |  4 ++++
 dlls/msvcrt/tests/string.c | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index f31ba60..96f67e0 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -1109,7 +1109,11 @@ MSVCRT_long CDECL MSVCRT__atol_l(const char *str, MSVCRT__locale_t locale)
  */
 MSVCRT_long CDECL MSVCRT_atol(const char *str)
 {
+#if _MSVCR_VER == 0
+    return MSVCRT_atoi(str);
+#else
     return MSVCRT__atol_l(str, NULL);
+#endif
 }
 
 #if _MSVCR_VER>=120
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index eb8e304..ff3a87d 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -3047,6 +3047,23 @@ static void test_atoi(void)
     ok(r == 0, "atoi(4294967296) = %d\n", r);
 }
 
+static void test_atol(void)
+{
+    int r;
+
+    r = atol("0");
+    ok(r == 0, "atol(0) = %d\n", r);
+
+    r = atol("-1");
+    ok(r == -1, "atol(-1) = %d\n", r);
+
+    r = atol("1");
+    ok(r == 1, "atol(1) = %d\n", r);
+
+    r = atol("4294967296");
+    ok(r == 0, "atol(4294967296) = %d\n", r);
+}
+
 static void test_atof(void)
 {
     double d;
@@ -3831,6 +3848,7 @@ START_TEST(string)
     test__stricmp();
     test__wcstoi64();
     test_atoi();
+    test_atol();
     test_atof();
     test_strncpy();
     test_strxfrm();




More information about the wine-cvs mailing list