[PATCH] appwiz.cpl: Avoid calling strlen on constants

Alex Henrie alexhenrie24 at gmail.com
Tue Feb 5 00:12:05 CST 2019


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/appwiz.cpl/appwiz.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/dlls/appwiz.cpl/appwiz.c b/dlls/appwiz.cpl/appwiz.c
index ee26e5825f..0039ef1073 100644
--- a/dlls/appwiz.cpl/appwiz.c
+++ b/dlls/appwiz.cpl/appwiz.c
@@ -203,11 +203,12 @@ static BOOL ReadApplicationsFromRegistry(HKEY root)
             if (!RegQueryValueExW(hkeyApp, WindowsInstallerW, NULL, &dwType, (LPBYTE)&value, &size)
                 && dwType == REG_DWORD && value == 1)
             {
-                static const WCHAR fmtW[] = {'m','s','i','e','x','e','c',' ','/','x','%','s',0};
-                int len = lstrlenW(fmtW) + lstrlenW(subKeyName);
+                static const WCHAR fmtW[] = {'m','s','i','e','x','e','c',' ','/','x',0};
+                int len = ARRAY_SIZE(fmtW) + lstrlenW(subKeyName);
 
                 if (!(command = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) goto err;
-                wsprintfW(command, fmtW, subKeyName);
+                lstrcpyW(command, fmtW);
+                lstrcpyW(command + ARRAY_SIZE(fmtW) - 1, subKeyName);
             }
             else if (!RegQueryValueExW(hkeyApp, UninstallCommandlineW, 0, 0, NULL, &uninstlen))
             {
@@ -289,11 +290,12 @@ static BOOL ReadApplicationsFromRegistry(HKEY root)
                 if (!RegQueryValueExW(hkeyApp, WindowsInstallerW, NULL, &dwType, (LPBYTE)&value, &size)
                     && dwType == REG_DWORD && value == 1)
                 {
-                    static const WCHAR fmtW[] = {'m','s','i','e','x','e','c',' ','/','i','%','s',0};
-                    int len = lstrlenW(fmtW) + lstrlenW(subKeyName);
+                    static const WCHAR fmtW[] = {'m','s','i','e','x','e','c',' ','/','i',0};
+                    int len = ARRAY_SIZE(fmtW) + lstrlenW(subKeyName);
 
                     if (!(info->path_modify = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) goto err;
-                    wsprintfW(info->path_modify, fmtW, subKeyName);
+                    lstrcpyW(info->path_modify, fmtW);
+                    lstrcpyW(info->path_modify + ARRAY_SIZE(fmtW) - 1, subKeyName);
                 }
                 else if (!RegQueryValueExW(hkeyApp, ModifyPathW, 0, 0, NULL, &displen))
                 {
-- 
2.20.1




More information about the wine-devel mailing list