From ebf78c19e18bb3b6cace19d4249cbb7f5c4b3df3 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Fri, 9 Mar 2018 17:48:56 -0800 Subject: [PATCH] memory leak --- libfprint/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libfprint/core.c b/libfprint/core.c index 9812440..3850121 100644 --- a/libfprint/core.c +++ b/libfprint/core.c @@ -564,10 +564,13 @@ 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. */ list = g_malloc(sizeof(*list) * (dscv_count + 1)); @@ -597,8 +600,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); } -- 2.14.3