Skip to content

Commit

Permalink
fix: Minor memory leak with -P. (#1103)
Browse files Browse the repository at this point in the history
For every new connection we saved the name of the congestion
control algorithm, but if there were multiple connections we'd
leak all but the last name.

Fixes #1100.
  • Loading branch information
bmah888 authored Jan 15, 2021
1 parent 21581a7 commit ce01004
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/iperf_server_api.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* iperf, Copyright (c) 2014-2020 The Regents of the University of
* iperf, Copyright (c) 2014-2021 The Regents of the University of
* California, through Lawrence Berkeley National Laboratory (subject
* to receipt of any required approvals from the U.S. Dept. of
* Energy). All rights reserved.
Expand Down Expand Up @@ -547,7 +547,16 @@ iperf_run_server(struct iperf_test *test)
i_errno = IESETCONGESTION;
return -1;
}
test->congestion_used = strdup(ca);
/*
* If not the first connection, discard prior
* congestion algorithm name so we don't leak
* duplicated strings. We probably don't need
* the old string anyway.
*/
if (test->congestion_used != NULL) {
free(test->congestion_used);
}
test->congestion_used = strdup(ca);
if (test->debug) {
printf("Congestion algorithm is %s\n", test->congestion_used);
}
Expand Down

0 comments on commit ce01004

Please sign in to comment.