Windows: Fix poll implementation for NDEBUG (Release) builds
authorChris Dickens <christopher.a.dickens@gmail.com>
Fri, 31 Jan 2020 04:48:56 +0000 (20:48 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 31 Jan 2020 04:48:56 +0000 (20:48 -0800)
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>
libusb/os/poll_windows.c
libusb/version_nano.h

index 830c7e5..f735245 100644 (file)
@@ -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;
index 18c8cb7..7e27bf5 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11452
+#define LIBUSB_NANO 11453