Windows: fd_to_winfd() shouldn't treat fd 0 as invalid
authorSimon Haggett <simon.haggett@realvnc.com>
Thu, 11 Jul 2013 16:27:00 +0000 (17:27 +0100)
committerPete Batard <pete@akeo.ie>
Wed, 7 Aug 2013 23:37:30 +0000 (00:37 +0100)
* fd_to_winfd() currently returns INVALID_WINFD if fd is 0, but usbi_create_fd()
  can legally assign an fd number of 0 if poll_fd[0] is not already occupied.
* Transfers which are assigned an fd number of 0 for their event handle are then
  unable to have their event handle retrieved later on.

See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-PATCH-1-1-Windows-fd-to-winfd-shouldn-t-treat-fd-0-as-invalid-tt1535.html

libusb/os/poll_windows.c

index 7ed19ba..abe8761 100644 (file)
@@ -428,7 +428,7 @@ struct winfd fd_to_winfd(int fd)
 
        CHECK_INIT_POLLING;
 
-       if (fd <= 0)
+       if (fd < 0)
                return INVALID_WINFD;
 
        for (i=0; i<MAX_FDS; i++) {