Skip to content

Commit

Permalink
Fixed segmentation fault in ykcore_libusb.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Detegr committed Feb 26, 2014
1 parent 5f8cfe6 commit a225525
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ykcore/ykcore_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extern int _ykusb_stop(void)
void *_ykusb_open_device(int vendor_id, int *product_ids, size_t pids_len)
{
struct usb_bus *bus;
struct usb_device *dev;
struct usb_device *dev, *yk_device;
struct usb_dev_handle *h = NULL;
int rc = YK_EUSBERR;
int found = 0;
Expand All @@ -164,6 +164,7 @@ void *_ykusb_open_device(int vendor_id, int *product_ids, size_t pids_len)
for (j = 0; j < pids_len; j++) {
if (dev->descriptor.idProduct == product_ids[j]) {
if(found == 0) {
yk_device = dev;
found = 1;
break;
} else {
Expand All @@ -177,7 +178,7 @@ void *_ykusb_open_device(int vendor_id, int *product_ids, size_t pids_len)
}
if(found == 1) {
rc = YK_EUSBERR;
h = usb_open(dev);
h = usb_open(yk_device);
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
if (h != NULL)
usb_detach_kernel_driver_np(h, 0);
Expand Down

0 comments on commit a225525

Please sign in to comment.