diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2021-04-13 19:44:59 +0200 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2021-04-13 21:00:12 +0100 |
commit | 81b9ea72f9982e7c25b09434492140d452acf215 (patch) | |
tree | a3e2d063bba1fc0ed5bd6e82a89b0507875c6bf4 | |
parent | ea2beb9a77205702d6f9517485d47af5a273b5a0 (diff) | |
download | gusb-81b9ea72f9982e7c25b09434492140d452acf215.tar.gz |
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.
-rw-r--r-- | gusb/gusb-device.c | 2 |
1 files changed, 0 insertions, 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", |