Piotr Caban : msvcrt: Fix floating point numbers scanning when null-byte is preceding the number.
Alexandre Julliard
julliard at winehq.org
Mon Jan 13 16:11:53 CST 2020
Module: wine
Branch: master
Commit: 287dabd9b6887e94cabfa2a5f9bfe822522095e5
URL: https://source.winehq.org/git/wine.git/?a=commit;h=287dabd9b6887e94cabfa2a5f9bfe822522095e5
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Jan 13 20:17:17 2020 +0100
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 <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 1833c42dc3..ec3ec79995 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 95fd043e6f..57d9cc0ba1 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);
More information about the wine-cvs
mailing list