advapi32: Fix RegDeleteTreeW when an empty string is passed.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6780c20342
commit
2ddcd97bb1
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue