From d54d49c0ac4693108f60f73a9e9c0e1c7cf24456 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Fri, 12 May 2017 09:12:48 -0700 Subject: Don't free memory in uninitialized structures Also, tighten up the scope/lifetime of some memory structures. Inspired by #577. --- src/iperf_tcp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/iperf_tcp.c') diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index 89eb864..3353030 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -136,8 +136,6 @@ iperf_tcp_accept(struct iperf_test * test) int iperf_tcp_listen(struct iperf_test *test) { - struct addrinfo hints, *res; - char portstr[6]; int s, opt; socklen_t optlen; int saved_errno; @@ -155,6 +153,9 @@ iperf_tcp_listen(struct iperf_test *test) * It's not clear whether this is a requirement or a convenience. */ if (test->no_delay || test->settings->mss || test->settings->socket_bufsize) { + struct addrinfo hints, *res; + char portstr[6]; + FD_CLR(s, &test->read_set); close(s); @@ -305,7 +306,6 @@ iperf_tcp_listen(struct iperf_test *test) if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, &sndbuf_actual, &optlen) < 0) { saved_errno = errno; close(s); - freeaddrinfo(res); errno = saved_errno; i_errno = IESETBUF; return -1; @@ -323,7 +323,6 @@ iperf_tcp_listen(struct iperf_test *test) if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, &rcvbuf_actual, &optlen) < 0) { saved_errno = errno; close(s); - freeaddrinfo(res); errno = saved_errno; i_errno = IESETBUF; return -1; -- cgit v1.2.3