Hans Leidekker : msi: Handle environment strings without a value.
Alexandre Julliard
julliard at winehq.org
Fri Nov 13 09:37:06 CST 2009
Module: wine
Branch: master
Commit: e52531ab1dae0e1edeb5787b545693ae5db0fd23
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e52531ab1dae0e1edeb5787b545693ae5db0fd23
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Nov 13 11:06:12 2009 +0100
msi: Handle environment strings without a value.
---
dlls/msi/action.c | 39 +++++++++++++++++++++++----------------
dlls/msi/tests/install.c | 10 +++++++++-
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index a6af7cc..3a11c61 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -4888,7 +4888,6 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package )
static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags )
{
LPCWSTR cptr = *name;
- LPCWSTR ptr = *value;
static const WCHAR prefix[] = {'[','~',']',0};
static const int prefix_len = 3;
@@ -4919,18 +4918,22 @@ static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags )
return ERROR_FUNCTION_FAILED;
}
- if (!strncmpW(ptr, prefix, prefix_len))
+ if (*value)
{
- *flags |= ENV_MOD_APPEND;
- *value += lstrlenW(prefix);
- }
- else if (lstrlenW(*value) >= prefix_len)
- {
- ptr += lstrlenW(ptr) - prefix_len;
- if (!lstrcmpW(ptr, prefix))
+ LPCWSTR ptr = *value;
+ if (!strncmpW(ptr, prefix, prefix_len))
{
- *flags |= ENV_MOD_PREFIX;
- /* the "[~]" will be removed by deformat_string */;
+ *flags |= ENV_MOD_APPEND;
+ *value += lstrlenW(prefix);
+ }
+ else if (lstrlenW(*value) >= prefix_len)
+ {
+ ptr += lstrlenW(ptr) - prefix_len;
+ if (!lstrcmpW(ptr, prefix))
+ {
+ *flags |= ENV_MOD_PREFIX;
+ /* the "[~]" will be removed by deformat_string */;
+ }
}
}
@@ -4978,8 +4981,7 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param )
if (res != ERROR_SUCCESS)
goto done;
- deformat_string(package, value, &deformatted);
- if (!deformatted)
+ if (value && !deformat_string(package, value, &deformatted))
{
res = ERROR_OUTOFMEMORY;
goto done;
@@ -5066,7 +5068,7 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param )
}
}
}
- else
+ else if (value)
{
size = (lstrlenW(value) + 1) * sizeof(WCHAR);
newval = msi_alloc(size);
@@ -5079,8 +5081,13 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param )
lstrcpyW(newval, value);
}
- TRACE("setting %s to %s\n", debugstr_w(name), debugstr_w(newval));
- res = RegSetValueExW(env, name, 0, type, (LPVOID)newval, size);
+ if (newval)
+ {
+ TRACE("setting %s to %s\n", debugstr_w(name), debugstr_w(newval));
+ res = RegSetValueExW(env, name, 0, type, (LPVOID)newval, size);
+ }
+ else
+ res = ERROR_SUCCESS;
done:
if (env) RegCloseKey(env);
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 6efd290..35bbc85 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -174,7 +174,9 @@ static const CHAR environment_dat[] = "Environment\tName\tValue\tComponent_\n"
"Var1\t=-MSITESTVAR1\t1\tOne\n"
"Var2\tMSITESTVAR2\t1\tOne\n"
"Var3\t=-MSITESTVAR3\t1\tOne\n"
- "Var4\tMSITESTVAR4\t1\tOne\n";
+ "Var4\tMSITESTVAR4\t1\tOne\n"
+ "Var5\t-MSITESTVAR5\t\tOne\n"
+ "Var6\tMSITESTVAR6\t\tOne\n";
static const CHAR condition_dat[] = "Feature_\tLevel\tCondition\n"
"s38\ti2\tS255\n"
@@ -6610,6 +6612,12 @@ static void test_envvar(void)
res = RegDeleteValueA(env, "MSITESTVAR4");
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ res = RegDeleteValueA(env, "MSITESTVAR5");
+ ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+
+ res = RegDeleteValueA(env, "MSITESTVAR6");
+ ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+
RegCloseKey(env);
delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
More information about the wine-cvs
mailing list