summaryrefslogtreecommitdiff
path: root/libgphoto2_port/libusb1
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2019-04-27 15:32:51 +0200
committerMarcus Meissner <marcus@jet.franken.de>2019-04-28 09:15:36 +0200
commit91531c47defc2fda486d110280ec77162c675d61 (patch)
treee7bb421ed8f97feb46455f6bf65f3474f511a064 /libgphoto2_port/libusb1
parent542940519f5c4768fb92186070d5d11b2e28d66a (diff)
downloadlibgphoto2-91531c47defc2fda486d110280ec77162c675d61.tar.gz
handle not devices a bit better
Diffstat (limited to 'libgphoto2_port/libusb1')
-rw-r--r--libgphoto2_port/libusb1/libusb1.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c
index 8b4a5c073..df42486de 100644
--- a/libgphoto2_port/libusb1/libusb1.c
+++ b/libgphoto2_port/libusb1/libusb1.c
@@ -213,6 +213,11 @@ gp_port_library_list (GPPortInfoList *list)
gp_port_info_list_append (list, info); /* do not check return value, it might be -1 */
nrofdevs = libusb_get_device_list (ctx, &devs);
+ if (!nrofdevs) {
+ libusb_exit (ctx); /* should free all stuff above */
+ goto nodevices;
+ }
+
C_MEM (descs = calloc (nrofdevs, sizeof(descs[0])));
for (i=0;i<nrofdevs;i++)
LOG_ON_LIBUSB_E (libusb_get_device_descriptor(devs[i], &descs[i]));
@@ -323,6 +328,7 @@ gp_port_library_list (GPPortInfoList *list)
libusb_exit (ctx); /* should free all stuff above */
free (descs);
+nodevices:
/* This will only be added if no other device was ever added.
* Users doing "usb:" usage will enter the regular expression matcher case. */
if (nrofdevices == 0) {