discovered_devs_append takes a reference to the past in dev, so we must
release our own reference.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 libusb/os/openbsd_usb.c | 5 ++++-
 libusb/version_nano.h   | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index 84c339e..e1be242 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -186,7 +186,9 @@ obsd_get_device_list(struct libusb_context * ctx,
                        session_id = (di.udi_bus << 8 | di.udi_addr);
                        dev = usbi_get_device_by_session_id(ctx, session_id);
 
-                       if (dev == NULL) {
+                       if (dev) {
+                               dev = libusb_ref_device(dev);
+                       } else {
                                dev = usbi_alloc_device(ctx, session_id);
                                if (dev == NULL) {
                                        close(fd);
@@ -226,6 +228,7 @@ obsd_get_device_list(struct libusb_context * ctx,
                                close(fd);
                                return (LIBUSB_ERROR_NO_MEM);
                        }
+                       libusb_unref_device(dev);
 
                        *discdevs = ddd;
                        devices[addr] = 1;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 1aa4bd5..d8a3c31 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10832
+#define LIBUSB_NANO 10833
-- 
1.8.3.1


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to