Commit ff0ee8f8 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

advapi32: Return an error from RegSetValueExW if passed a NULL data pointer and non-zero size.

parent 823c037c
......@@ -1201,7 +1201,7 @@ LSTATUS WINAPI RegSetValueExW( HKEY hkey, LPCWSTR name, DWORD reserved,
/* no need for version check, not implemented on win9x anyway */
if (data && ((ULONG_PTR)data >> 16) == 0) return ERROR_NOACCESS;
if ((data && ((ULONG_PTR)data >> 16) == 0) || (!data && count)) return ERROR_NOACCESS;
if (count && is_string(type))
{
......
......@@ -436,6 +436,21 @@ static void test_set_value(void)
ret = RegSetValueExW(hkey_main, name2W, 0, REG_DWORD, (const BYTE *)1, 1);
ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
if (pRegGetValueA) /* avoid a crash on Windows 2000 */
{
ret = RegSetValueExW(hkey_main, NULL, 0, REG_SZ, NULL, 4);
ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
ret = RegSetValueExW(hkey_main, NULL, 0, REG_SZ, NULL, 0);
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
ret = RegSetValueExW(hkey_main, NULL, 0, REG_DWORD, NULL, 4);
ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
ret = RegSetValueExW(hkey_main, NULL, 0, REG_DWORD, NULL, 0);
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
}
/* RegSetKeyValue */
if (!pRegSetKeyValueW)
win_skip("RegSetKeyValue() is not supported.\n");
......@@ -464,6 +479,12 @@ static void test_set_value(void)
ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_SZ, NULL, 0);
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_SZ, NULL, 4);
ok(ret == ERROR_NOACCESS, "got %d\n", ret);
ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_DWORD, NULL, 4);
ok(ret == ERROR_NOACCESS, "got %d\n", ret);
RegCloseKey(subkey);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment