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;
return ERROR_FUNCTION_FAILED;
}
+ if (*value)
+ {
+ LPCWSTR ptr = *value;
if (!strncmpW(ptr, prefix, prefix_len))
{
*flags |= ENV_MOD_APPEND;
/* the "[~]" will be removed by deformat_string */;
}
}
+ }
if (check_flag_combo(*flags, ENV_ACT_SETALWAYS | ENV_ACT_SETABSENT) ||
check_flag_combo(*flags, ENV_ACT_REMOVEMATCH | ENV_ACT_SETABSENT) ||
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;
}
}
}
- else
+ else if (value)
{
size = (lstrlenW(value) + 1) * sizeof(WCHAR);
newval = msi_alloc(size);
lstrcpyW(newval, value);
}
+ 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);