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.
Normally, we don't see this problem occuring as pipes created by libusb_init() for the context will occupy the low numbered entries of poll_fd. However, if two libusb contexts are created, and the first context is then destroyed, the second context will likely find that poll_fd[0] is now free. A transfer subsequently sent using the second context can then have its event handle assigned fd number 0. This patch corrects fd_to_winfd() to only consider fd values less than zero as invalid. Signed-off-by: Simon Haggett <simon.hagg...@realvnc.com> --- libusb/os/poll_windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 7ed19ba..abe8761 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -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++) { -- 1.8.1.msysgit.1 ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel