Michael Stefaniuc : sapi: Zero terminate some WCHAR strings.

Alexandre Julliard julliard at winehq.org
Wed Oct 28 15:58:17 CDT 2020


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

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Wed Oct 28 00:39:09 2020 +0100

sapi: Zero terminate some WCHAR strings.

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

---

 dlls/sapi/token.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c
index b4a318b4ade..04fa3a25d6a 100644
--- a/dlls/sapi/token.c
+++ b/dlls/sapi/token.c
@@ -372,28 +372,28 @@ static HRESULT WINAPI token_category_EnumValues( ISpObjectTokenCategory *iface,
 
 static HRESULT parse_cat_id( const WCHAR *str, HKEY *root, const WCHAR **sub_key )
 {
-    static const WCHAR HKLM[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E','\\'};
-    static const WCHAR HKCU[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\'};
     struct table
     {
         const WCHAR *name;
-        int size;
+        unsigned int len;
         HKEY key;
     } table[] =
     {
-        { HKLM, sizeof(HKLM), HKEY_LOCAL_MACHINE },
-        { HKCU, sizeof(HKCU), HKEY_CURRENT_USER },
+#define X(s)  s, ARRAY_SIZE(s) - 1
+        { X(L"HKEY_LOCAL_MACHINE\\"), HKEY_LOCAL_MACHINE },
+        { X(L"HKEY_CURRENT_USER\\"), HKEY_CURRENT_USER },
         { NULL }
+#undef X
     };
     struct table *ptr;
     int len = lstrlenW( str );
 
     for (ptr = table; ptr->name; ptr++)
     {
-        if (len >= ptr->size / sizeof(ptr->name[0]) && !memcmp( str, ptr->name, ptr->size ))
+        if (len >= ptr->len && !wcsncmp( str, ptr->name, ptr->len ))
         {
             *root = ptr->key;
-            *sub_key = str + ptr->size / sizeof(ptr->name[0]);
+            *sub_key = str + ptr->len;
             return S_OK;
         }
     }




More information about the wine-cvs mailing list