diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-12-22 11:13:01 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-12-22 11:13:01 -0500 |
commit | 13f26f41e469ae2fa5d2249c532f7f515195a2a0 (patch) | |
tree | c59de8f13db8b2268cc2d1daad86b57ecd2926d6 /src | |
parent | ec07c3c5c5c4afe19816b1d5363d9b9acd4c484c (diff) | |
download | tor-13f26f41e469ae2fa5d2249c532f7f515195a2a0.tar.gz tor-13f26f41e469ae2fa5d2249c532f7f515195a2a0.zip |
Fix some coverity issues in the unit tests
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_channel.c | 10 | ||||
-rw-r--r-- | src/test/test_dir.c | 8 | ||||
-rw-r--r-- | src/test/test_microdesc.c | 3 | ||||
-rw-r--r-- | src/test/test_relay.c | 1 |
4 files changed, 17 insertions, 5 deletions
diff --git a/src/test/test_channel.c b/src/test/test_channel.c index f882b99906..b1f1bdb435 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -1566,12 +1566,15 @@ test_channel_write(void *arg) old_count = test_cells_written; channel_write_cell(ch, cell); + cell = NULL; tt_assert(test_cells_written == old_count + 1); channel_write_var_cell(ch, var_cell); + var_cell = NULL; tt_assert(test_cells_written == old_count + 2); channel_write_packed_cell(ch, packed_cell); + packed_cell = NULL; tt_assert(test_cells_written == old_count + 3); /* Now we test queueing; tell it not to accept cells */ @@ -1632,15 +1635,18 @@ test_channel_write(void *arg) cell = tor_malloc_zero(sizeof(cell_t)); make_fake_cell(cell); channel_write_cell(ch, cell); + cell = NULL; tt_assert(test_cells_written == old_count); var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE); make_fake_var_cell(var_cell); channel_write_var_cell(ch, var_cell); + var_cell = NULL; tt_assert(test_cells_written == old_count); packed_cell = packed_cell_new(); channel_write_packed_cell(ch, packed_cell); + packed_cell = NULL; tt_assert(test_cells_written == old_count); #ifdef ENABLE_MEMPOOLS @@ -1649,7 +1655,9 @@ test_channel_write(void *arg) done: tor_free(ch); - + tor_free(var_cell); + tor_free(cell); + packed_cell_free(packed_cell); return; } diff --git a/src/test/test_dir.c b/src/test/test_dir.c index e5328fed56..2659fbcfb8 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -605,6 +605,7 @@ test_dir_load_routers(void *arg) smartlist_t *wanted = smartlist_new(); char buf[DIGEST_LEN]; char *mem_op_hex_tmp = NULL; + char *list = NULL; #define ADD(str) \ do { \ @@ -630,7 +631,7 @@ test_dir_load_routers(void *arg) /* Not ADDing BAD_PORTS */ ADD(EX_RI_BAD_TOKENS); - char *list = smartlist_join_strings(chunks, "", 0, NULL); + list = smartlist_join_strings(chunks, "", 0, NULL); tt_int_op(1, OP_EQ, router_load_routers_from_string(list, NULL, SAVED_IN_JOURNAL, wanted, 1, NULL)); @@ -670,6 +671,7 @@ test_dir_load_routers(void *arg) smartlist_free(chunks); SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp)); smartlist_free(wanted); + tor_free(list); } static int mock_get_by_ei_dd_calls = 0; @@ -722,6 +724,7 @@ test_dir_load_extrainfo(void *arg) smartlist_t *wanted = smartlist_new(); char buf[DIGEST_LEN]; char *mem_op_hex_tmp = NULL; + char *list = NULL; #define ADD(str) \ do { \ @@ -746,7 +749,7 @@ test_dir_load_extrainfo(void *arg) ADD(EX_EI_BAD_TOKENS); ADD(EX_EI_BAD_SIG2); - char *list = smartlist_join_strings(chunks, "", 0, NULL); + list = smartlist_join_strings(chunks, "", 0, NULL); router_load_extrainfo_from_string(list, NULL, SAVED_IN_JOURNAL, wanted, 1); /* The "maximal" router was added. */ @@ -788,6 +791,7 @@ test_dir_load_extrainfo(void *arg) smartlist_free(chunks); SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp)); smartlist_free(wanted); + tor_free(list); } static void diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 4a7c29b747..31ed93b720 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -703,8 +703,7 @@ test_md_reject_cache(void *arg) done: UNMOCK(networkstatus_get_latest_consensus_by_flavor); UNMOCK(router_get_mutable_consensus_status_by_descriptor_digest); - if (options) - tor_free(options->DataDirectory); + tor_free(options->DataDirectory); microdesc_free_all(); smartlist_free(added); SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp)); diff --git a/src/test/test_relay.c b/src/test/test_relay.c index 6907597705..38d1d96703 100644 --- a/src/test/test_relay.c +++ b/src/test/test_relay.c @@ -114,6 +114,7 @@ test_relay_append_cell_to_circuit_queue(void *arg) nchan = pchan = NULL; done: + tor_free(cell); tor_free(orcirc); if (nchan && nchan->cmux) circuitmux_free(nchan->cmux); tor_free(nchan); |