diff options
author | scf <scf@FreeBSD.org> | 2009-12-12 00:24:30 +0000 |
---|---|---|
committer | scf <scf@FreeBSD.org> | 2009-12-12 00:24:30 +0000 |
commit | 26de328278d4a8cb7491ca3495b2706220b88c2f (patch) | |
tree | d37514939301bede19eca6f8f94696847718e012 /lib/libusb/libusb10.c | |
parent | 02d6bc865e1f58465f2167b67513dd7d30489736 (diff) | |
download | FreeBSD-src-26de328278d4a8cb7491ca3495b2706220b88c2f.zip FreeBSD-src-26de328278d4a8cb7491ca3495b2706220b88c2f.tar.gz |
Fix libusb_open_device_with_vid_pid() to return a NULL if no device is
found instead of the last device in its search list.
Reviewed by: thompsa
MFC after: 5 days
Diffstat (limited to 'lib/libusb/libusb10.c')
-rw-r--r-- | lib/libusb/libusb10.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 9a5154e..25520d2 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -379,8 +379,6 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, if ((i = libusb_get_device_list(ctx, &devs)) < 0) return (NULL); - pdev = NULL; - for (j = 0; j < i; j++) { pdev = devs[j]->os_priv; pdesc = libusb20_dev_get_device_desc(pdev); @@ -396,6 +394,8 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, break; } } + if (j == i) + pdev = NULL; libusb_free_device_list(devs, 1); DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); |