diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 52de6c5d427..3762908aff1 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -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; diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 47e76b28634..ca82fa13186 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -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 */