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>
stable
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;
}
/* 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. */
{

View File

@ -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 },