From 287dabd9b6887e94cabfa2a5f9bfe822522095e5 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 13 Jan 2020 20:17:17 +0100 Subject: [PATCH] msvcrt: Fix floating point numbers scanning when null-byte is preceding the number. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48452 Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/scanf.h | 2 ++ dlls/msvcrt/tests/scanf.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h index 1833c42dc3d..ec3ec799955 100644 --- a/dlls/msvcrt/scanf.h +++ b/dlls/msvcrt/scanf.h @@ -393,6 +393,8 @@ _FUNCTION_ { /* skip initial whitespace */ while ((nch!=_EOF_) && _ISSPACE_(nch)) nch = _GETC_(file); + if (nch == _EOF_) + break; ctx.unget = nch; #ifdef STRING ctx.file = file; diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c index 95fd043e6f0..57d9cc0ba12 100644 --- a/dlls/msvcrt/tests/scanf.c +++ b/dlls/msvcrt/tests/scanf.c @@ -165,6 +165,12 @@ static void test_sscanf( void ) ok(double_res >= 1.1e-30-1e-45 && double_res <= 1.1e-30+1e-45, "Got %.18le, expected %.18le\n", double_res, 1.1e-30); + buffer[0] = 0; + double_res = 1; + ret = p_sscanf(buffer, "%lf", &double_res); + ok(ret == -1, "expected 0, got %u\n", ret); + ok(double_res == 1, "Got %lf, expected 1\n", double_res); + /* check strings */ ret = p_sprintf(buffer," %s", pname); ok( ret == 26, "expected 26, got %u\n", ret); -- 2.11.4.GIT