summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-02-04 22:50:28 +0100
committerTormod Volden <debian.tormod@gmail.com>2022-03-15 11:43:05 +0100
commitc3639bc23eaaed7fa94d377af42f00ddc5083de2 (patch)
treef9f3e7b24f2b4f6e4f92914a6ed7c188faae02b5
parent4622bfcf44db373c53502e3fe873bd611e8332f6 (diff)
downloadlibusb-c3639bc23eaaed7fa94d377af42f00ddc5083de2.tar.gz
core: Unset device ctx if it has been destroyed
Devices can outlive their context in some cases (in particular with python garbage collection). Guard against this by clearing the ctx pointer so that it is not pointing to uninitialized memory. Closes #1058
-rw-r--r--libusb/core.c1
-rw-r--r--libusb/version_nano.h2
2 files changed, 2 insertions, 1 deletions
diff --git a/libusb/core.c b/libusb/core.c
index 7893ac2..1c1ada1 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -2441,6 +2441,7 @@ void API_EXPORTED libusb_exit(libusb_context *ctx)
for_each_device(_ctx, dev) {
usbi_warn(_ctx, "device %d.%d still referenced",
dev->bus_number, dev->device_address);
+ DEVICE_CTX(dev) = NULL;
}
if (!list_empty(&_ctx->open_devs))
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 03df9b4..2b170fc 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11692
+#define LIBUSB_NANO 11693