msvcrt: Don't overwrite unmatched string in scanf.

This commit is contained in:
Piotr Caban 2014-01-16 11:39:44 +01:00 committed by Alexandre Julliard
parent 7341996f5d
commit 638c8e3847
2 changed files with 9 additions and 2 deletions

View File

@ -478,7 +478,7 @@ _FUNCTION_ {
if (width>0) width--;
}
/* terminate */
if (!suppress) *sptr = 0;
if (st && !suppress) *sptr = 0;
}
break;
widecharstring: { /* read a word into a wchar_t* */
@ -508,7 +508,7 @@ _FUNCTION_ {
if (width>0) width--;
}
/* terminate */
if (!suppress) *sptr = 0;
if (st && !suppress) *sptr = 0;
}
break;
/* 'c' and 'C work analogously to 's' and 'S' as described

View File

@ -131,6 +131,13 @@ static void test_sscanf( void )
ok( ret == 1, "Error with format \"%s\"\n","%*[a-cd-dg-e]%c");
ok( buffer[0] == 'h', "Error with \"abcefgdh\" \"%c\"\n", buffer[0]);
buffer1[0] = 'b';
ret = sscanf("a","%s%s", buffer, buffer1);
ok( ret == 1, "expected 1, got %u\n", ret);
ok( buffer[0] == 'a', "buffer[0] = '%c'\n", buffer[0]);
ok( buffer[1] == '\0', "buffer[1] = '%c'\n", buffer[1]);
ok( buffer1[0] == 'b', "buffer1[0] = '%c'\n", buffer1[0]);
/* check digits */
ret = sprintf(buffer,"%d:%d:%d",hour,min,sec);
ok( ret == 8, "expected 8, got %u\n", ret);