summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2014-12-16 19:19:50 +0000
committerPete Batard <pete@akeo.ie>2014-12-16 19:19:50 +0000
commit63cd7d193cfd78712bfc0a74cb35cf76dc55f55d (patch)
tree259791ca8f6e2d93bdb79d6a4879e1c49e420c12
parentd37635afb2e845210c80c0765dccad98933e72d0 (diff)
downloadlibusb-63cd7d193cfd78712bfc0a74cb35cf76dc55f55d.tar.gz
Windows: fix 2 bugs in windows_handle_events()
* Var found was not reset to false before list_for_each_entry() * ctx->open_devs_lock was not released on error. * Issues reported by Yongjian Xu
-rw-r--r--libusb/os/windows_usb.c4
-rw-r--r--libusb/version_nano.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 20ca448..0ce0dfc 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -2252,7 +2252,7 @@ static int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds,
{
struct windows_transfer_priv* transfer_priv = NULL;
POLL_NFDS_TYPE i = 0;
- bool found = false;
+ bool found;
struct usbi_transfer *transfer;
DWORD io_size, io_result;
@@ -2270,6 +2270,7 @@ static int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds,
// Because a Windows OVERLAPPED is used for poll emulation,
// a pollable fd is created and stored with each transfer
usbi_mutex_lock(&ctx->flying_transfers_lock);
+ found = false;
list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
transfer_priv = usbi_transfer_get_os_priv(transfer);
if (transfer_priv->pollable_fd.fd == fds[i].fd) {
@@ -2297,6 +2298,7 @@ static int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds,
// newly allocated wfd that took the place of the one from the transfer.
windows_handle_callback(transfer, io_result, io_size);
} else {
+ usbi_mutex_unlock(&ctx->open_devs_lock);
usbi_err(ctx, "could not find a matching transfer for fd %x", fds[i]);
return LIBUSB_ERROR_NOT_FOUND;
}
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 0c23ca6..5a80112 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10923
+#define LIBUSB_NANO 10924