diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2019-04-27 15:32:51 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2019-04-28 09:15:36 +0200 |
commit | 91531c47defc2fda486d110280ec77162c675d61 (patch) | |
tree | e7bb421ed8f97feb46455f6bf65f3474f511a064 /libgphoto2_port/libusb1 | |
parent | 542940519f5c4768fb92186070d5d11b2e28d66a (diff) | |
download | libgphoto2-91531c47defc2fda486d110280ec77162c675d61.tar.gz |
handle not devices a bit better
Diffstat (limited to 'libgphoto2_port/libusb1')
-rw-r--r-- | libgphoto2_port/libusb1/libusb1.c | 6 |
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) { |