diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index c3c2950d3d4..53b645910d1 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -3253,20 +3253,15 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer goto cleanup; } - /* Expand environment variables, if appropriate, or copy the original string over. */ - if (dwValueType == REG_EXPAND_SZ) { - cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR); - if (!cbData) goto cleanup; - pwszExpandedBuffer = heap_alloc(cbData); - if (!pwszExpandedBuffer) { - result = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData / sizeof(WCHAR)); - } else { - pwszExpandedBuffer = heap_alloc(cbData); - memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData); + /* Expand environment variables regardless of the type. */ + cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR); + if (!cbData) goto cleanup; + pwszExpandedBuffer = heap_alloc(cbData); + if (!pwszExpandedBuffer) { + result = ERROR_NOT_ENOUGH_MEMORY; + goto cleanup; } + ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData / sizeof(WCHAR)); /* Parse the value and load the string. */ { diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index a1b9dd1c399..855f5a8dcc8 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3862,7 +3862,7 @@ static void test_RegLoadMUIString(void) { "@unknown.dll", REG_SZ, TRUE, ERROR_INVALID_DATA, 0, TRUE }, { "@unknown.dll,-10", REG_SZ, TRUE, ERROR_FILE_NOT_FOUND }, /* 4 */ - { with_env_var, REG_SZ, FALSE, ERROR_SUCCESS, 0, TRUE }, + { with_env_var, REG_SZ, FALSE, ERROR_SUCCESS }, { with_env_var, REG_EXPAND_SZ, FALSE, ERROR_SUCCESS }, { "%WineMuiTest1%", REG_EXPAND_SZ, TRUE, ERROR_INVALID_DATA }, { "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS },