diff options
author | Benjamin Berg <bberg@redhat.com> | 2022-02-04 22:50:28 +0100 |
---|---|---|
committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2023-04-05 11:08:52 +0200 |
commit | 7bc9a0a16eff16f6a7f42e5d15021ab3eaf8e7f9 (patch) | |
tree | 77434af08ffe37e0587589f8788a3b20d739a097 | |
parent | a53eb1e32b7fad12a2ee82a62be254758ad20f8d (diff) | |
download | libusb-7bc9a0a16eff16f6a7f42e5d15021ab3eaf8e7f9.tar.gz libusb-7bc9a0a16eff16f6a7f42e5d15021ab3eaf8e7f9.tar.bz2 libusb-7bc9a0a16eff16f6a7f42e5d15021ab3eaf8e7f9.zip |
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
[Cherrypick from mainline commit c3639bc ("core: Unset device ctx if it has been destroyed")]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: Ic1a27aea2b29d07c93d96d98a684facc799b4259
-rw-r--r-- | libusb/core.c | 1 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
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 |