diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 2dd75bea3a9..a34c863af3e 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -1401,10 +1401,12 @@ NTSTATUS WINAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path) TRACE("(%d, %s)\n", RelativeTo, debugstr_w(Path)); - if((!RelativeTo) && Path == NULL) + if(!RelativeTo && (Path == NULL || Path[0] == 0)) return STATUS_OBJECT_PATH_SYNTAX_BAD; if(RelativeTo & RTL_REGISTRY_HANDLE) return STATUS_SUCCESS; + if((RelativeTo <= RTL_REGISTRY_USER) && (Path == NULL || Path[0] == 0)) + return STATUS_SUCCESS; status = RTL_GetKeyHandle(RelativeTo, Path, &handle); if (handle) NtClose(handle); diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index 7d2e56644c8..ddd400ee029 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -671,6 +671,7 @@ static void test_RtlOpenCurrentUser(void) static void test_RtlCheckRegistryKey(void) { + static WCHAR empty[] = {0}; NTSTATUS status; status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, winetestpath.Buffer); @@ -678,6 +679,18 @@ static void test_RtlCheckRegistryKey(void) status = pRtlCheckRegistryKey((RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL), winetestpath.Buffer); ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and RTL_REGISTRY_OPTIONAL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, NULL); + ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being NULL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, empty); + ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being empty: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, NULL); + ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being NULL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, empty); + ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being empty: 0x%08x\n", status); } static void test_NtFlushKey(void)