aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-07-15 13:26:47 -0400
committerNick Mathewson <nickm@torproject.org>2013-07-18 08:45:03 -0400
commit31871f7d774b5d18b5cf62ac44a8a2b41f87a8c1 (patch)
treed66aa701da865e31254399f8919511c758bc7da4 /src
parent713ff2f5efb91adf147edf22ec0def2f4d17badb (diff)
downloadtor-31871f7d774b5d18b5cf62ac44a8a2b41f87a8c1.tar
tor-31871f7d774b5d18b5cf62ac44a8a2b41f87a8c1.tar.gz
Fix memory leaks in test_config_parse_transport_options_line
Diffstat (limited to 'src')
-rw-r--r--src/test/test_config.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 7c43b5f61..3848d352d 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -441,7 +441,7 @@ test_config_parse_bridge_line(void *arg)
static void
test_config_parse_transport_options_line(void *arg)
{
- smartlist_t *options_sl = NULL;
+ smartlist_t *options_sl = NULL, *sl_tmp = NULL;
(void) arg;
@@ -462,7 +462,7 @@ test_config_parse_transport_options_line(void *arg)
}
{ /* correct -- no transport specified */
- smartlist_t *sl_tmp = smartlist_new();
+ sl_tmp = smartlist_new();
smartlist_add_asprintf(sl_tmp, "ladi=dadi");
smartlist_add_asprintf(sl_tmp, "weliketo=party");
@@ -474,12 +474,14 @@ test_config_parse_transport_options_line(void *arg)
SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
smartlist_free(sl_tmp);
+ sl_tmp = NULL;
SMARTLIST_FOREACH(options_sl, char *, s, tor_free(s));
smartlist_free(options_sl);
+ options_sl = NULL;
}
{ /* correct -- correct transport specified */
- smartlist_t *sl_tmp = smartlist_new();
+ sl_tmp = smartlist_new();
smartlist_add_asprintf(sl_tmp, "ladi=dadi");
smartlist_add_asprintf(sl_tmp, "weliketo=party");
@@ -488,15 +490,23 @@ test_config_parse_transport_options_line(void *arg)
"rook");
test_assert(options_sl);
test_assert(smartlist_strings_eq(options_sl, sl_tmp));
-
SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
smartlist_free(sl_tmp);
+ sl_tmp = NULL;
SMARTLIST_FOREACH(options_sl, char *, s, tor_free(s));
smartlist_free(options_sl);
+ options_sl = NULL;
}
done:
- ;
+ if (options_sl) {
+ SMARTLIST_FOREACH(options_sl, char *, s, tor_free(s));
+ smartlist_free(options_sl);
+ }
+ if (sl_tmp) {
+ SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
+ smartlist_free(sl_tmp);
+ }
}
#define CONFIG_TEST(name, flags) \