diff --git a/examples/img_capture.c b/examples/img_capture.c index 6528031..1bf896c 100644 --- a/examples/img_capture.c +++ b/examples/img_capture.c @@ -28,7 +28,7 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs) struct fp_driver *drv; if (!ddev) return NULL; - + drv = fp_dscv_dev_get_driver(ddev); printf("Found device claimed by %s driver\n", fp_driver_get_full_name(drv)); return ddev; @@ -57,6 +57,7 @@ int main(void) ddev = discover_device(discovered_devs); if (!ddev) { + fp_dscv_devs_free(discovered_devs); fprintf(stderr, "No devices detected.\n"); goto out; } @@ -102,4 +103,3 @@ out: fp_exit(); return r; } - diff --git a/libfprint/core.c b/libfprint/core.c index 522213e..b09e16c 100644 --- a/libfprint/core.c +++ b/libfprint/core.c @@ -69,7 +69,7 @@ GSList *opened_devices = NULL; * * Verification is what most people think of when they think about fingerprint * scanning. The process of verification is effectively performing a fresh - * fingerprint scan, and then comparing that scan to a finger that was + * fingerprint scan, and then comparing that scan to a finger that was * previously enrolled. * * As an example scenario, verification can be used to implement what people @@ -561,9 +561,11 @@ API_EXPORTED struct fp_dscv_dev **fp_discover_devs(void) struct fp_dscv_dev *ddev = discover_dev(udev); if (!ddev) continue; + libusb_ref_device(udev); tmplist = g_slist_prepend(tmplist, (gpointer) ddev); dscv_count++; } + libusb_free_device_list(devs, 1); /* Convert our temporary GSList into a standard NULL-terminated pointer * array. */ @@ -594,8 +596,10 @@ API_EXPORTED void fp_dscv_devs_free(struct fp_dscv_dev **devs) if (!devs) return; - for (i = 0; devs[i]; i++) + for (i = 0; devs[i]; i++){ + libusb_unref_device(devs[i]->udev); g_free(devs[i]); + } g_free(devs); } @@ -969,4 +973,3 @@ API_EXPORTED void fp_exit(void) registered_drivers = NULL; libusb_exit(fpi_usb_ctx); } -