aboutsummaryrefslogtreecommitdiff
path: root/src/iperf_tcp.c
diff options
context:
space:
mode:
authorBruce A. Mah <bmah@es.net>2017-05-12 09:12:48 -0700
committerBruce A. Mah <bmah@es.net>2017-05-12 09:12:48 -0700
commitd54d49c0ac4693108f60f73a9e9c0e1c7cf24456 (patch)
treebe78ff83792585fc14a1e4c7fc9d443b9839d461 /src/iperf_tcp.c
parentec04a41e7866e4cb3cfe2f097bfcdda662c544f2 (diff)
downloadiperf3-d54d49c0ac4693108f60f73a9e9c0e1c7cf24456.tar.gz
Don't free memory in uninitialized structures
Also, tighten up the scope/lifetime of some memory structures. Inspired by #577.
Diffstat (limited to 'src/iperf_tcp.c')
-rw-r--r--src/iperf_tcp.c7
1 files changed, 3 insertions, 4 deletions
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;