This patch closes a critical memory leak in handle_events. The fds
variable is malloced but never freed. When I'm calling
handle_events with a timeout of 0, my system runs out of memory after a
few seconds.
r = poll(fds, nfds, timeout_ms);
usbi_dbg("poll() returned %d", r);
if (r == 0) {
+ free(fds);
return handle_timeouts();
} else if (r == -1 && errno == EINTR) {
+ free(fds);
return LIBUSB_ERROR_INTERRUPTED;
} else if (r < 0) {
+ free(fds);
usbi_err("poll failed %d err=%d\n", r, errno);
return LIBUSB_ERROR_IO;
}
if (r)
usbi_err("backend handle_events failed with error %d", r);
+ free(fds);
return r;
}