From 8c1684a50a56bdafe38fa5c685f6b367f8a44bc5 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Sat, 16 Mar 2019 14:49:08 +0100 Subject: [PATCH] msvcrt: Don't detect overflow in atol implementation. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46845 Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- 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 f31ba60630d..96f67e064a0 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 eb8e3041073..ff3a87d69dc 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();