libusb-compat-0.1 icon indicating copy to clipboard operation
libusb-compat-0.1 copied to clipboard

libusb-compat-0.1 devices still referenced upon exit

Open mcuee opened this issue 2 years ago • 4 comments

Reference:

  • https://github.com/libusb/libusb/issues/988
  • https://github.com/libusb/libusb/issues/974

I am not so sure if this is an issue with libusb-compat-0.1 or libusb.

mcuee avatar Jan 28 '23 03:01 mcuee

Reference:

  • https://github.com/libusb/libusb/issues/988#issuecomment-1492954364

The following fix to libusb-compat-0.1 seems to fix the issue. But I am not so sure if it is the right fix or not.

mcuee@UbuntuSwift3:~/build/libusb-compat-0.1$ git diff
diff --git a/libusb/core.c b/libusb/core.c
index 3bc9c25..09068f3 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -584,14 +584,12 @@ static int initialize_device(struct usb_device *dev)
        dev->num_children = 0;
        dev->children = NULL;
 
-       libusb_ref_device(newlib_dev);
        return 0;
 }
 
 static void free_device(struct usb_device *dev)
 {
        clear_device(dev);
-       libusb_unref_device(dev->dev);
        free(dev);
 }

mcuee avatar Oct 12 '23 11:10 mcuee

Comments welcome.

mcuee avatar Oct 12 '23 11:10 mcuee

@tormodvolden

Please take a look at the proposed fix. Thanks. It seems to me this is not a bug of libusb but rather libusb-compat-0.1.

mcuee avatar Dec 21 '23 14:12 mcuee