diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2020-01-30 20:48:56 -0800 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2020-01-30 20:48:56 -0800 |
commit | 67e6816264e35a1f22b43a78b4be7481652bc51a (patch) | |
tree | b317acbf9af7960083f68b013d8ba2e2f0c87fdf | |
parent | ce95f656adcda701888c7414d2ab0f88f3f2c0ae (diff) | |
download | libusb-67e6816264e35a1f22b43a78b4be7481652bc51a.tar.gz |
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 <christopher.a.dickens@gmail.com>
-rw-r--r-- | libusb/os/poll_windows.c | 4 | ||||
-rw-r--r-- | 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 |