From: Alex Henrie Subject: [PATCH] appwiz.cpl: Avoid calling strlen on constants Message-Id: <20190205061238.13905-2-alexhenrie24@gmail.com> Date: Mon, 4 Feb 2019 23:12:05 -0700 In-Reply-To: <20190205061238.13905-1-alexhenrie24@gmail.com> References: <20190205061238.13905-1-alexhenrie24@gmail.com> Signed-off-by: Alex Henrie --- 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