mirror of
https://github.com/RPCS3/libusb.git
synced 2026-01-31 01:25:19 +01:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 10589
|
||||
#define LIBUSB_NANO 10590
|
||||
|
||||
Reference in New Issue
Block a user