Skip to content

Commit

Permalink
libusb: Add missing checks after new_hid_device
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Sep 27, 2024
1 parent 11031f3 commit 57f104f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libusb/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,10 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
return NULL;

dev = new_hid_device();
if (!dev) {
LOG("hid_open_path failed: Couldn't allocate memory\n");
return NULL;
}

libusb_get_device_list(usb_context, &devs);
while ((usb_dev = devs[d++]) != NULL && !good_open) {
Expand Down Expand Up @@ -1381,6 +1385,10 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_libusb_wrap_sys_device(intptr_t sys
return NULL;

dev = new_hid_device();
if (!dev) {
LOG("libusb_wrap_sys_device failed: Couldn't allocate memory\n");
return NULL;
}

res = libusb_wrap_sys_device(usb_context, sys_dev, &dev->device_handle);
if (res < 0) {
Expand Down

0 comments on commit 57f104f

Please sign in to comment.