ntdll: Fix source/destination confusion in vsscanf.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-01-05 16:09:30 +01:00
parent 0bdd879fde
commit 62a1410a07

View File

@ -1178,19 +1178,19 @@ static int NTDLL_vsscanf( const char *str, const char *format, __ms_va_list ap)
else goto widecharacter; else goto widecharacter;
character: character:
{ /* read single character into char */ { /* read single character into char */
char *str = suppress ? NULL : va_arg( ap, char * ); char *sptr = suppress ? NULL : va_arg( ap, char * );
char *pstr = str; char *sptr_beg = sptr;
unsigned size = UINT_MAX; unsigned size = UINT_MAX;
if (width == -1) width = 1; if (width == -1) width = 1;
while (width && nch != '\0') while (width && nch != '\0')
{ {
if (!suppress) if (!suppress)
{ {
*str++ = nch; *sptr++ = nch;
if(size) size--; if(size) size--;
else else
{ {
*pstr = 0; *sptr_beg = 0;
return rd; return rd;
} }
} }
@ -1202,19 +1202,19 @@ static int NTDLL_vsscanf( const char *str, const char *format, __ms_va_list ap)
break; break;
widecharacter: widecharacter:
{ /* read single character into a WCHAR */ { /* read single character into a WCHAR */
WCHAR *str = suppress ? NULL : va_arg( ap, WCHAR * ); WCHAR *sptr = suppress ? NULL : va_arg( ap, WCHAR * );
WCHAR *pstr = str; WCHAR *sptr_beg = sptr;
unsigned size = UINT_MAX; unsigned size = UINT_MAX;
if (width == -1) width = 1; if (width == -1) width = 1;
while (width && nch != '\0') while (width && nch != '\0')
{ {
if (!suppress) if (!suppress)
{ {
*str++ = nch; *sptr++ = nch;
if (size) size--; if (size) size--;
else else
{ {
*pstr = 0; *sptr_beg = 0;
return rd; return rd;
} }
} }
@ -1248,10 +1248,10 @@ static int NTDLL_vsscanf( const char *str, const char *format, __ms_va_list ap)
break; break;
case '[': case '[':
{ {
char *str = suppress ? NULL : va_arg( ap, char * ); char *sptr = suppress ? NULL : va_arg( ap, char * );
char *sptr = str; char *sptr_beg = sptr;
RTL_BITMAP bitMask; RTL_BITMAP bitMask;
ULONG Mask[8]; ULONG Mask[8] = { 0 };
BOOLEAN invert = FALSE; /* Set if we are NOT to find the chars */ BOOLEAN invert = FALSE; /* Set if we are NOT to find the chars */
unsigned size = UINT_MAX; unsigned size = UINT_MAX;
@ -1312,7 +1312,7 @@ static int NTDLL_vsscanf( const char *str, const char *format, __ms_va_list ap)
if(size > 1) size--; if(size > 1) size--;
else else
{ {
*str = 0; if (!suppress) *sptr_beg = 0;
return rd; return rd;
} }
} }