mirror of
https://github.com/shadps4-emu/ext-libusb.git
synced 2026-01-31 00:55:21 +01:00
Fix segmentation fault in libusb_init() if usbi_backend.init() fails
If the backend init fails, the control goes to err_io_exit which tries to clean up hotplug related lists that aren't initialized. Moving hotplug_init before makes sure the lists are valid so if backend init fails they get cleaned up without errors. Closes #989
This commit is contained in:
committed by
Tormod Volden
parent
7d7733a377
commit
6929b82701
@@ -2342,13 +2342,14 @@ int API_EXPORTED libusb_init(libusb_context **ctx)
|
||||
list_add(&_ctx->list, &active_contexts_list);
|
||||
usbi_mutex_static_unlock(&active_contexts_lock);
|
||||
|
||||
usbi_hotplug_init(_ctx);
|
||||
|
||||
if (usbi_backend.init) {
|
||||
r = usbi_backend.init(_ctx);
|
||||
if (r)
|
||||
goto err_io_exit;
|
||||
}
|
||||
|
||||
usbi_hotplug_init(_ctx);
|
||||
|
||||
if (ctx)
|
||||
*ctx = _ctx;
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 11653
|
||||
#define LIBUSB_NANO 11654
|
||||
|
||||
Reference in New Issue
Block a user