Core: Fix incorrect reference counting of default context when first created.

* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-stress-program-crashes-in-libusb-exit-NULL-tp474p477.html
This commit is contained in:
Toby Gray
2012-11-26 13:25:05 +00:00
committed by Pete Batard
parent 21cf6e4748
commit ce75e9af3f
2 changed files with 2 additions and 5 deletions

View 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);

View File

@@ -1 +1 @@
#define LIBUSB_NANO 10589
#define LIBUSB_NANO 10590