winecfg: Fix crash caused by calling set_reg_key with NULL value.

This commit is contained in:
Nigel Liang 2007-08-03 18:34:57 -07:00 committed by Alexandre Julliard
parent 402b8f0d59
commit 4536a9d66d
1 changed files with 7 additions and 3 deletions

View File

@ -464,15 +464,19 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons
void set_reg_key(HKEY root, const char *path, const char *name, const char *value) void set_reg_key(HKEY root, const char *path, const char *name, const char *value)
{ {
WCHAR *wpath, *wname, *wvalue; WCHAR *wpath, *wname, *wvalue = NULL;
wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR)); wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR)); wname = HeapAlloc(GetProcessHeap(), 0, (strlen(name)+1)*sizeof(WCHAR));
wvalue = HeapAlloc(GetProcessHeap(), 0, (strlen(value)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1); MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1); MultiByteToWideChar(CP_ACP, 0, name, -1, wname, strlen(name)+1);
MultiByteToWideChar(CP_ACP, 0, value, -1, wvalue, strlen(value)+1);
if (value)
{
wvalue = HeapAlloc(GetProcessHeap(), 0, (strlen(value)+1)*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, value, -1, wvalue, strlen(value)+1);
}
set_reg_key_ex(root, wpath, wname, wvalue, REG_SZ); set_reg_key_ex(root, wpath, wname, wvalue, REG_SZ);