From c7ddebaa6cf0bf108b9fa9f4b3bd3b7d5a8c89a4 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Fri, 3 Jan 2014 11:19:26 -0800 Subject: [PATCH] Fix memory leaks in iperf_reset_test(). Submitted by: Susant Sahani --- src/iperf_api.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index d439f45..2ceebd4 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1614,12 +1614,25 @@ iperf_reset_test(struct iperf_test *test) test->omit = OMIT; test->duration = DURATION; test->server_affinity = -1; - test->title = NULL; - test->congestion = NULL; test->state = 0; - test->server_hostname = NULL; - test->bind_address = NULL; + if(test->title) { + free(test->title); + test->title = NULL; + } + if(test->server_hostname) { + free(test->server_hostname); + test->server_hostname = NULL; + } + if(test->bind_address) { + free(test->bind_address); + test->bind_address = NULL; + } + if(test->congestion) { + free(test->congestion); + test->congestion = NULL; + } + test->ctrl_sck = -1; test->prot_listener = -1;