Skip to content

Commit 87a8bc6

Browse files
committed
Added an error message
1 parent ea5182d commit 87a8bc6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

windows/hid.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ int HID_API_EXPORT hid_init(void)
386386
register_global_error(NULL);
387387
if (!hid_hotplug_context.mutex) {
388388
hid_hotplug_context.mutex = CreateMutexA(NULL, FALSE, NULL);
389+
if(!hid_hotplug_context.mutex) {
390+
register_global_error(L"Failed to create hotplug management mutex");
391+
}
389392
}
390393
#ifndef HIDAPI_USE_DDK
391394
if (!hidapi_initialized) {
@@ -410,9 +413,11 @@ static void hid_internal_cleanup_hotplugs()
410413
hid_hotplug_context.devs = NULL;
411414
}
412415

413-
if (CM_Unregister_Notification(hid_hotplug_context.notify_handle) != CR_SUCCESS) {
414-
register_global_error(L"hid_hotplug_deregister_callback/CM_Unregister_Notification");
415-
return;
416+
if (hid_hotplug_context.notify_handle) {
417+
if (CM_Unregister_Notification(hid_hotplug_context.notify_handle) != CR_SUCCESS) {
418+
register_global_error(L"hid_hotplug_deregister_callback/CM_Unregister_Notification");
419+
return;
420+
}
416421
}
417422

418423
hid_hotplug_context.notify_handle = NULL;

0 commit comments

Comments
 (0)