commit f4cbcde2da39dec4be26aa1d2ffcb4d26603e1fa Author: David Goulet dgoulet@torproject.org Date: Mon Dec 21 13:10:58 2020 -0500
test: Fix memleak in test/load_stats_file
Signed-off-by: David Goulet dgoulet@torproject.org --- src/test/test_stats.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/test/test_stats.c b/src/test/test_stats.c index 7262477d77..d45afc7b15 100644 --- a/src/test/test_stats.c +++ b/src/test/test_stats.c @@ -515,6 +515,7 @@ test_load_stats_file(void *arg) tt_str_op(read_file_content, OP_EQ, content);
/* Load hidserv-stats. */ + tor_free(fname); fname = get_datadir_fname("hidserv-stats"); tt_assert(fname); tor_free(read_file_content); @@ -524,7 +525,6 @@ test_load_stats_file(void *arg) "bin_size=1024\n" "hidserv-dir-onions-seen 53 delta_f=8 epsilon=0.30 bin_size=8\n"); write_str_to_file(fname, read_file_content, 0); - tor_free(fname); tor_free(content); ret = load_stats_file("hidserv-stats", "hidserv-stats-end", 1607874000, &content); @@ -532,6 +532,7 @@ test_load_stats_file(void *arg) tt_str_op(read_file_content, OP_EQ, content);
/* Load dirreq-stats. */ + tor_free(fname); fname = get_datadir_fname("dirreq-stats"); tt_assert(fname); tor_free(read_file_content); @@ -546,7 +547,6 @@ test_load_stats_file(void *arg) "d1=133653,d2=221050,q1=261242,d3=300622,d4=399758,md=539051,d6=721322," "d7=959866,q3=1103363,d8=1302035,d9=2046125,max=113404000\n"); write_str_to_file(fname, read_file_content, 0); - tor_free(fname); tor_free(content); ret = load_stats_file("dirreq-stats", "dirreq-stats-end", 1607874000, &content); @@ -554,6 +554,7 @@ test_load_stats_file(void *arg) tt_str_op(read_file_content, OP_EQ, content);
/* Attempt to load future-stats file not starting with timestamp tag. */ + tor_free(fname); fname = get_datadir_fname("future-stats"); tt_assert(fname); tor_free(read_file_content); @@ -561,7 +562,6 @@ test_load_stats_file(void *arg) "future-stuff-at-file-start\n" "future-stats 2020-12-13 15:48:53 (86400 s)\n"); write_str_to_file(fname, read_file_content, 0); - tor_free(fname); tor_free(content); ret = load_stats_file("future-stats", "future-stats", 1607874000, &content); tt_int_op(ret, OP_EQ, 1);