From 65e550d265c481ff80d796622258c7177b36d745 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Tue, 26 May 2020 23:01:36 +0300 Subject: [PATCH] user32: Fix NULL dereference in UnregisterDeviceNotification. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49211 Signed-off-by: Arkadiusz Hiler Signed-off-by: Alexandre Julliard --- dlls/sechost/service.c | 3 +++ dlls/user32/tests/input.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/dlls/sechost/service.c b/dlls/sechost/service.c index 924a6c9264d..68d2b9e78e6 100644 --- a/dlls/sechost/service.c +++ b/dlls/sechost/service.c @@ -2109,6 +2109,9 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle ) TRACE("%p\n", handle); + if (!handle) + return FALSE; + EnterCriticalSection( &service_cs ); list_remove( ®istration->entry ); LeaveCriticalSection(&service_cs); diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 92b18becd2a..913fabfbd85 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3004,6 +3004,12 @@ static void test_GetPointerType(void) ok(type == PT_MOUSE, " type %d\n", type ); } +static void test_UnregisterDeviceNotification(void) +{ + BOOL ret = UnregisterDeviceNotification(NULL); + ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret); +} + START_TEST(input) { POINT pos; @@ -3050,4 +3056,6 @@ START_TEST(input) test_GetPointerType(); else win_skip("GetPointerType is not available\n"); + + test_UnregisterDeviceNotification(); }