Alexandre Julliard : ntdll: Fix source/destination confusion in vsscanf.

Alexandre Julliard julliard at winehq.org
Fri Jan 5 14:02:03 CST 2018


Module: wine
Branch: master
Commit: 62a1410a07476ac94acceaf2a9e65628d4b06ddc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=62a1410a07476ac94acceaf2a9e65628d4b06ddc

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Jan  5 16:09:30 2018 +0100

ntdll: Fix source/destination confusion in vsscanf.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/string.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

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




More information about the wine-cvs mailing list