From 67e6816264e35a1f22b43a78b4be7481652bc51a Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Thu, 30 Jan 2020 20:48:56 -0800 Subject: Windows: Fix poll implementation for NDEBUG (Release) builds The refactoring in commit df61c0c3a3 ("Windows: improve poll abstraction") introduced a bug in builds where NDEBUG is defined because of a statement with side-effects that was put inside an assertion. When this statement is not evaluated, the file descriptor table gets corrupt. Fix this by moving the statement outside of the assertion. Signed-off-by: Chris Dickens --- libusb/os/poll_windows.c | 4 +++- libusb/version_nano.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 830c7e5..f735245 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -135,12 +135,14 @@ static int install_fd(struct file_descriptor *fd) for (n = 0; n < fd_table_size; n += BITMAP_BITS_PER_WORD) { unsigned int idx = n / BITMAP_BITS_PER_WORD; ULONG mask, pos = 0U; + unsigned char nonzero; mask = ~fd_table_bitmap[idx]; if (mask == 0U) continue; - assert(_BitScanForward(&pos, mask)); + nonzero = _BitScanForward(&pos, mask); + assert(nonzero); fd_table_bitmap[idx] |= 1U << pos; n += pos; break; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 18c8cb7..7e27bf5 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11452 +#define LIBUSB_NANO 11453 -- cgit v1.2.1