RegDeleteKey fails if the lpSubKey param is NULL.

This commit is contained in:
James Hawkins 2005-04-16 10:49:10 +00:00 committed by Alexandre Julliard
parent 13578c8602
commit a9d5de8414
2 changed files with 15 additions and 2 deletions

View File

@ -871,9 +871,11 @@ DWORD WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
DWORD ret;
HKEY tmp;
if (!name) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
if (!name || !*name)
if (!*name)
{
ret = RtlNtStatusToDosError( NtDeleteKey( hkey ) );
}
@ -905,9 +907,11 @@ DWORD WINAPI RegDeleteKeyA( HKEY hkey, LPCSTR name )
DWORD ret;
HKEY tmp;
if (!name) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
if (!name || !*name)
if (!*name)
{
ret = RtlNtStatusToDosError( NtDeleteKey( hkey ) );
}

View File

@ -352,6 +352,14 @@ static void test_reg_close_key()
"expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", ret);
}
static void test_reg_delete_key()
{
DWORD ret;
ret = RegDeleteKey(hkey_main, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", ret);
}
static void test_reg_save_key()
{
DWORD ret;
@ -385,6 +393,7 @@ START_TEST(registry)
test_query_value_ex();
test_reg_open_key();
test_reg_close_key();
test_reg_delete_key();
test_reg_save_key();
test_reg_load_key();