From: Piotr Caban Subject: [PATCH] ucrtbase: Fix end pointer setting in parse_double on partial nan/infinity match. Message-Id: <64f6baf7-9602-086b-ac9e-280b7456ac9c@codeweavers.com> Date: Tue, 7 Jan 2020 15:35:52 +0100 Signed-off-by: Piotr Caban --- dlls/msvcrt/string.c | 4 ++++ dlls/ucrtbase/tests/string.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 78a115550c..c4bd8ab129 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -706,7 +706,11 @@ double parse_double(MSVCRT_wchar_t (*get)(void *ctx), void (*unget)(void *ctx), if(keep) { if (str_match == _infinity) return sign*INFINITY; if (str_match == _nan) return sign*NAN; + } else if(found_sign) { + unget(ctx); } + + return make_double(sign, exp, d, ROUND_ZERO, err); } if(nch == '0') { diff --git a/dlls/ucrtbase/tests/string.c b/dlls/ucrtbase/tests/string.c index 0bb3feaa2f..c18b5483aa 100644 --- a/dlls/ucrtbase/tests/string.c +++ b/dlls/ucrtbase/tests/string.c @@ -144,6 +144,8 @@ static void test_strtod(void) test_strtod_str("inf42", INFINITY, 3); test_strtod_str("inffoo", INFINITY, 3); test_strtod_str("infini", INFINITY, 3); + test_strtod_str("input", 0, 0); + test_strtod_str("-input", 0, 0); test_strtod_str("NAN", NAN, 3); test_strtod_str("nan", NAN, 3);