Commit 2ddcd97b authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

advapi32: Fix RegDeleteTreeW when an empty string is passed.

parent 6780c203
......@@ -3030,7 +3030,7 @@ LSTATUS WINAPI RegDeleteTreeW( HKEY hkey, const WCHAR *subkey )
TRACE( "(%p, %s)\n", hkey, debugstr_w(subkey) );
if (subkey)
if (subkey && *subkey)
{
ret = RegOpenKeyExW( hkey, subkey, 0, KEY_READ, &hkey );
if (ret) return ret;
......@@ -3060,7 +3060,7 @@ LSTATUS WINAPI RegDeleteTreeW( HKEY hkey, const WCHAR *subkey )
}
/* Delete the key itself */
if (subkey)
if (subkey && *subkey)
{
ret = RegDeleteKeyW( hkey, emptyW );
goto cleanup;
......@@ -3081,7 +3081,7 @@ LSTATUS WINAPI RegDeleteTreeW( HKEY hkey, const WCHAR *subkey )
cleanup:
heap_free( name_buf );
if (subkey)
if (subkey && *subkey)
RegCloseKey( hkey );
return ret;
}
......
......@@ -2246,6 +2246,20 @@ static void test_reg_delete_tree(void)
dwsize = MAX_PATH;
ok(RegQueryValueExA(subkey, "value", NULL, &type, (BYTE *)buffer, &dwsize),
"Value is still present\n");
ret = RegCloseKey(subkey);
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
ret = RegOpenKeyA(hkey_main, "subkey", &subkey);
ok(ret == ERROR_SUCCESS, "subkey was deleted\n");
ret = pRegDeleteTreeA(subkey, "");
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
ret = RegCloseKey(subkey);
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
ret = RegOpenKeyA(hkey_main, "subkey", &subkey);
ok(ret == ERROR_SUCCESS, "subkey was deleted\n");
ret = RegCloseKey(subkey);
ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
ret = pRegDeleteTreeA(hkey_main, "not-here");
ok(ret == ERROR_FILE_NOT_FOUND,
......
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