advapi32: Expand environment variables even if REG_SZ type is used.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2019-05-26 21:15:05 +09:00 committed by Alexandre Julliard
parent 1ed4c150a2
commit e798d25f25
2 changed files with 9 additions and 14 deletions

View File

@ -3253,20 +3253,15 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
goto cleanup; goto cleanup;
} }
/* Expand environment variables, if appropriate, or copy the original string over. */ /* Expand environment variables regardless of the type. */
if (dwValueType == REG_EXPAND_SZ) { cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR);
cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR); if (!cbData) goto cleanup;
if (!cbData) goto cleanup; pwszExpandedBuffer = heap_alloc(cbData);
pwszExpandedBuffer = heap_alloc(cbData); if (!pwszExpandedBuffer) {
if (!pwszExpandedBuffer) { result = ERROR_NOT_ENOUGH_MEMORY;
result = ERROR_NOT_ENOUGH_MEMORY; goto cleanup;
goto cleanup;
}
ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData / sizeof(WCHAR));
} else {
pwszExpandedBuffer = heap_alloc(cbData);
memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData);
} }
ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData / sizeof(WCHAR));
/* Parse the value and load the string. */ /* Parse the value and load the string. */
{ {

View File

@ -3862,7 +3862,7 @@ static void test_RegLoadMUIString(void)
{ "@unknown.dll", REG_SZ, TRUE, ERROR_INVALID_DATA, 0, TRUE }, { "@unknown.dll", REG_SZ, TRUE, ERROR_INVALID_DATA, 0, TRUE },
{ "@unknown.dll,-10", REG_SZ, TRUE, ERROR_FILE_NOT_FOUND }, { "@unknown.dll,-10", REG_SZ, TRUE, ERROR_FILE_NOT_FOUND },
/* 4 */ /* 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 }, { with_env_var, REG_EXPAND_SZ, FALSE, ERROR_SUCCESS },
{ "%WineMuiTest1%", REG_EXPAND_SZ, TRUE, ERROR_INVALID_DATA }, { "%WineMuiTest1%", REG_EXPAND_SZ, TRUE, ERROR_INVALID_DATA },
{ "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS }, { "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS },