core: Unlock and clear default ctx in all error paths in libusb_init
authorMatthias Bolte <matthias@tinkerforge.com>
Wed, 22 Sep 2021 11:40:23 +0000 (13:40 +0200)
committerNathan Hjelm <hjelmn@me.com>
Wed, 24 Nov 2021 06:02:43 +0000 (23:02 -0700)
commitd4452bd5554b2e6cc7017ad9cdba54a848cf5e93
tree7439a111799e5cea50310f4c7d208087464a07ec
parent683e3cf21ed37d4492c20cea8de810c4d95ae8b6
core: Unlock and clear default ctx in all error paths in libusb_init

Commit 32a22069428cda9d63aa666e92fb8882a83d4515 reordered and
refactored libusb_init. This resulted in moving code outside the
default ctx lock that was unrelated to it. But this resulted in
broken error path cleanup logic that leaves the default ctx as
locked, half initialized and freed in case a libusb_set_option or
the usbi_io_init call fails.

Undo part of the previous reordering to unlock and clear the default
ctx in all error paths in libusb_init.

Closes #995

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
libusb/core.c
libusb/version_nano.h