Commit 0ca3b3b4 authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

advapi32: Check the output pointer first in RegOpenKey, with test.

parent 5a91cffc
......@@ -381,6 +381,9 @@ LSTATUS WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM acc
*/
LSTATUS WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, PHKEY retkey )
{
if (!retkey)
return ERROR_INVALID_PARAMETER;
if (!name || !*name)
{
*retkey = hkey;
......@@ -402,10 +405,13 @@ LSTATUS WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, PHKEY retkey )
*
* RETURNS
* Success: ERROR_SUCCESS
* Failure: A standard Win32 error code. retkey is set to 0.
* Failure: A standard Win32 error code. When retkey is valid, *retkey is set to 0.
*/
LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
{
if (!retkey)
return ERROR_INVALID_PARAMETER;
if (!name || !*name)
{
*retkey = hkey;
......
......@@ -956,9 +956,18 @@ static void test_reg_open_key(void)
RegCloseKey(hkResult);
/* send in NULL hkResult */
SetLastError(0xdeadbeef);
ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
SetLastError(0xdeadbeef);
ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
SetLastError(0xdeadbeef);
ret = RegOpenKeyA(NULL, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
/* beginning backslash character */
ret = RegOpenKeyA(HKEY_CURRENT_USER, "\\Software\\Wine\\Test", &hkResult);
ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */
......
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