From 81b9ea72f9982e7c25b09434492140d452acf215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 13 Apr 2021 19:44:59 +0200 Subject: device: Do not double-reference USB devices Currently gusb-device adds two references to an internal libusb device, causing a memory leak on destruction. In fact, we add a reference when the device is constructed and when the device is inited. To avoid this and ensure that libusb will cleanup all the devices on context destruction, only reference on device initialization. --- gusb/gusb-device.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c index 4637cf3..4aa1071 100644 --- a/gusb/gusb-device.c +++ b/gusb/gusb-device.c @@ -146,8 +146,6 @@ g_usb_device_constructed (GObject *object) if (!priv->device) g_error("constructed without a libusb_device"); - libusb_ref_device(priv->device); - rc = libusb_get_device_descriptor (priv->device, &priv->desc); if (rc != LIBUSB_SUCCESS) g_warning ("Failed to get USB descriptor for device: %s", -- cgit v1.2.1