Michael Stefaniuc : advpack: Don't use sizeof to calculate the length of a WCHAR string.

Alexandre Julliard julliard at winehq.org
Wed Oct 7 16:04:09 CDT 2020


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

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Wed Oct  7 00:51:56 2020 +0200

advpack: Don't use sizeof to calculate the length of a WCHAR string.

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

---

 dlls/advpack/install.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c
index d82de9c361..24e2c4579a 100644
--- a/dlls/advpack/install.c
+++ b/dlls/advpack/install.c
@@ -446,10 +446,6 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
     LPCWSTR ptr, path;
 
     static const WCHAR backslash[] = {'\\',0};
-    static const WCHAR default_install[] = {
-        'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0
-    };
-
     if (!(ptr = wcsrchr(inf_filename, '\\')))
         ptr = inf_filename;
 
@@ -464,16 +460,16 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
     /* FIXME: determine the proper platform to install (NTx86, etc) */
     if (!install_sec || !*install_sec)
     {
-        len = sizeof(default_install) - 1;
-        ptr = default_install;
+        len = ARRAY_SIZE(L"DefaultInstall");
+        ptr = L"DefaultInstall";
     }
     else
     {
-        len = lstrlenW(install_sec);
+        len = lstrlenW(install_sec) + 1;
         ptr = install_sec;
     }
 
-    info->install_sec = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
+    info->install_sec = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
     if (!info->install_sec)
         return E_OUTOFMEMORY;
 




More information about the wine-cvs mailing list