diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-26 14:48:30 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-29 12:48:02 -0400 |
commit | aa0eb2022342798fc78b2bde89d393f37c59fe78 (patch) | |
tree | 559c4913bd41265a2cbe3b07b031c90c19fabeb5 /src/test/test_config.c | |
parent | ee9ed9d817ebfb9101030ed0f899871ba8113b74 (diff) | |
download | tor-aa0eb2022342798fc78b2bde89d393f37c59fe78.tar.gz tor-aa0eb2022342798fc78b2bde89d393f37c59fe78.zip |
Fix leaks in tests related to setting options->DataDirectory
We pre-populate that value in main(), and we weren't freeing it
before overriding it.
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r-- | src/test/test_config.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c index 82bc92dc08..d3e32525ee 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -196,9 +196,9 @@ static void test_config_check_or_create_data_subdir(void *arg) { or_options_t *options = get_options_mutable(); - char *datadir = options->DataDirectory = tor_strdup(get_fname("datadir-0")); + char *datadir; const char *subdir = "test_stats"; - char *subpath = get_datadir_fname(subdir); + char *subpath; struct stat st; int r; #if !defined (_WIN32) || defined (WINCE) @@ -206,6 +206,10 @@ test_config_check_or_create_data_subdir(void *arg) #endif (void)arg; + tor_free(options->DataDirectory); + datadir = options->DataDirectory = tor_strdup(get_fname("datadir-0")); + subpath = get_datadir_fname(subdir); + #if defined (_WIN32) && !defined (WINCE) tt_int_op(mkdir(options->DataDirectory), ==, 0); #else @@ -254,7 +258,7 @@ static void test_config_write_to_data_subdir(void *arg) { or_options_t* options = get_options_mutable(); - char *datadir = options->DataDirectory = tor_strdup(get_fname("datadir-1")); + char *datadir; char *cp = NULL; const char* subdir = "test_stats"; const char* fname = "test_file"; @@ -276,6 +280,9 @@ test_config_write_to_data_subdir(void *arg) char* filepath = get_datadir_fname2(subdir, fname); (void)arg; + tor_free(options->DataDirectory); + datadir = options->DataDirectory = tor_strdup(get_fname("datadir-1")); + #if defined (_WIN32) && !defined (WINCE) tt_int_op(mkdir(options->DataDirectory), ==, 0); #else |