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

This commit is contained in:
Detlef Riekenberg 2009-06-28 20:40:04 +02:00 committed by Alexandre Julliard
parent 5a91cffc20
commit 0ca3b3b423
2 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -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 */