summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Engraf <david.engraf@netcom.eu>2008-05-19 15:13:38 +0100
committerDaniel Drake <dsd@gentoo.org>2008-05-19 15:13:38 +0100
commite44396a458ecea9e5edd9a7577e617571c76860d (patch)
tree65396bf6d0f60e7fb0f23de40728c8d11efa95b0
parenteb25630f52bc9848b444e439632c899977d887b0 (diff)
downloadlibusb-e44396a458ecea9e5edd9a7577e617571c76860d.tar.gz
critical memory leak in handle_events
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.
-rw-r--r--libusb/io.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 19b62c2..9bb3abb 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -930,10 +930,13 @@ static int handle_events(struct timeval *tv)
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;
}
@@ -942,6 +945,7 @@ static int handle_events(struct timeval *tv)
if (r)
usbi_err("backend handle_events failed with error %d", r);
+ free(fds);
return r;
}