Core: Fix incorrect reference counting of default context when first created.
authorToby Gray <toby.gray@realvnc.com>
Mon, 26 Nov 2012 13:25:05 +0000 (13:25 +0000)
committerPete Batard <pete@akeo.ie>
Mon, 26 Nov 2012 22:25:47 +0000 (22:25 +0000)
* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-stress-program-crashes-in-libusb-exit-NULL-tp474p477.html

libusb/core.c
libusb/version_nano.h

index 07b0b04..729bce3 100644 (file)
@@ -1655,6 +1655,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
        /* default context should be initialized before calling usbi_dbg */
        if (!usbi_default_context) {
                usbi_default_context = ctx;
+               default_context_refcnt++;
                usbi_dbg("created default context");
        }
 
@@ -1681,10 +1682,6 @@ int API_EXPORTED libusb_init(libusb_context **context)
 
        if (context) {
                *context = ctx;
-       } else if (!usbi_default_context) {
-               usbi_dbg("created default context");
-               usbi_default_context = ctx;
-               default_context_refcnt++;
        }
        usbi_mutex_static_unlock(&default_context_lock);
 
index ef6b500..27680c6 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10589
+#define LIBUSB_NANO 10590