From e94df274cee3d78526cacf91bc92b0ad70bff182 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Mon, 18 Sep 2006 13:55:25 +0200 Subject: [PATCH] ntdll: Fixed conditional expression (Coverity). --- dlls/ntdll/reg.c | 2 +- dlls/ntdll/tests/reg.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index e77c48a382d..bd32a3d1a5e 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -517,7 +517,7 @@ NTSTATUS WINAPI RtlpNtQueryValueKey( HANDLE handle, ULONG *result_type, PBYTE de UNICODE_STRING name; NTSTATUS ret; DWORD dwResultLen; - DWORD dwLen = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + result_len ? *result_len : 0; + DWORD dwLen = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + (result_len ? *result_len : 0); info = (KEY_VALUE_PARTIAL_INFORMATION*)RtlAllocateHeap( GetProcessHeap(), 0, dwLen ); if (!info) diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index c9fab3ab62f..252a8155c35 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -103,6 +103,7 @@ static NTSTATUS (WINAPI * pRtlUnicodeStringToAnsiString)(PSTRING, PUNICODE_STRIN static NTSTATUS (WINAPI * pRtlFreeHeap)(PVOID, ULONG, PVOID); static NTSTATUS (WINAPI * pRtlAllocateHeap)(PVOID,ULONG,ULONG); static NTSTATUS (WINAPI * pRtlZeroMemory)(PVOID, ULONG); +static NTSTATUS (WINAPI * pRtlpNtQueryValueKey)(HANDLE,ULONG*,PBYTE,DWORD*); static HMODULE hntdll = 0; static int CurrentTest = 0; @@ -146,6 +147,7 @@ static BOOL InitFunctionPtrs(void) NTDLL_GET_PROC(RtlFreeHeap) NTDLL_GET_PROC(RtlAllocateHeap) NTDLL_GET_PROC(RtlZeroMemory) + NTDLL_GET_PROC(RtlpNtQueryValueKey) } return TRUE; } @@ -445,6 +447,14 @@ static void test_NtDeleteKey(void) ok(status == STATUS_SUCCESS, "NtDeleteKey Failed: 0x%08lx\n", status); } +static void test_RtlpNtQueryValueKey(void) +{ + NTSTATUS status; + + status = pRtlpNtQueryValueKey(NULL, NULL, NULL, NULL); + ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got: 0x%08lx\n", status); +} + START_TEST(reg) { static const WCHAR winetest[] = {'\\','W','i','n','e','T','e','s','t','\\',0}; @@ -463,6 +473,7 @@ START_TEST(reg) test_RtlCheckRegistryKey(); test_RtlOpenCurrentUser(); test_RtlQueryRegistryValues(); + test_RtlpNtQueryValueKey(); test_NtFlushKey(); test_NtDeleteKey();