core: Add missing mutex acquisition when manipulating active_contexts_list

The `active_contexts_list` is supposed to be protected by the
`active_contexts_lock` mutex.

Upon code review, found one place where the mutex was not acquired.

Closes #1413
This commit is contained in:
Sean McBride
2023-12-30 00:43:29 -05:00
committed by Tormod Volden
parent a8fba21b7f
commit 7ab9c93d7d
2 changed files with 3 additions and 1 deletions

View File

@@ -2445,10 +2445,12 @@ int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_i
}
/* check for first init */
usbi_mutex_static_lock(&active_contexts_lock);
if (!active_contexts_list.next) {
list_init(&active_contexts_list);
usbi_get_monotonic_time(&timestamp_origin);
}
usbi_mutex_static_unlock(&active_contexts_lock);
_ctx = calloc(1, PTR_ALIGN(sizeof(*_ctx)) + priv_size);
if (!_ctx) {

View File

@@ -1 +1 @@
#define LIBUSB_NANO 11862
#define LIBUSB_NANO 11863