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

Alexandre Julliard julliard at winehq.org
Mon May 27 14:50:20 CDT 2019


Module: wine
Branch: master
Commit: e798d25f255b205cb6d765f042eb6ca3dfcf566a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e798d25f255b205cb6d765f042eb6ca3dfcf566a

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Sun May 26 21:15:05 2019 +0900

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

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/advapi32/registry.c       | 21 ++++++++-------------
 dlls/advapi32/tests/registry.c |  2 +-
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index c3c2950..53b6459 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 a1b9dd1..855f5a8 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 },




More information about the wine-cvs mailing list