diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-09-12 17:15:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-12 19:03:04 -0400 |
commit | 0f58e173134698a813d23288dabc22f2591e9dc2 (patch) | |
tree | 33a4f77791f3ba5eac0520d89a4cfe3807067ae5 /src | |
parent | 4097d646d81310ceefbe9a3f6873aaaca6af138e (diff) | |
download | tor-0f58e173134698a813d23288dabc22f2591e9dc2.tar.gz tor-0f58e173134698a813d23288dabc22f2591e9dc2.zip |
clang scan-build: Fix "dereference of null pointer" warnings
These warnings are all in the tests, and happen because something
that one part of the code checks for null-ness is later
dereferenced.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_hs_client.c | 8 | ||||
-rw-r--r-- | src/test/test_hs_service.c | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c index af5f5cb576..6714daceae 100644 --- a/src/test/test_hs_client.c +++ b/src/test/test_hs_client.c @@ -203,7 +203,8 @@ test_e2e_rend_circuit_setup_legacy(void *arg) done: connection_free_(conn); - tor_free(TO_CIRCUIT(or_circ)->n_chan); + if (or_circ) + tor_free(TO_CIRCUIT(or_circ)->n_chan); circuit_free(TO_CIRCUIT(or_circ)); } @@ -212,7 +213,7 @@ static void test_e2e_rend_circuit_setup(void *arg) { uint8_t ntor_key_seed[DIGEST256_LEN] = {0}; - origin_circuit_t *or_circ; + origin_circuit_t *or_circ = NULL; int retval; connection_t *conn = NULL; @@ -272,7 +273,8 @@ test_e2e_rend_circuit_setup(void *arg) done: connection_free_(conn); - tor_free(TO_CIRCUIT(or_circ)->n_chan); + if (or_circ) + tor_free(TO_CIRCUIT(or_circ)->n_chan); circuit_free(TO_CIRCUIT(or_circ)); } diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 05ced17ff7..8a6a6c3281 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -677,6 +677,8 @@ test_intro_established(void *arg) circ = helper_create_origin_circuit(CIRCUIT_PURPOSE_S_ESTABLISH_INTRO, flags); + tt_assert(circ); + /* Test a wrong purpose. */ TO_CIRCUIT(circ)->purpose = CIRCUIT_PURPOSE_S_INTRO; setup_full_capture_of_logs(LOG_WARN); @@ -724,7 +726,8 @@ test_intro_established(void *arg) tt_int_op(TO_CIRCUIT(circ)->purpose, OP_EQ, CIRCUIT_PURPOSE_S_INTRO); done: - circuit_free(TO_CIRCUIT(circ)); + if (circ) + circuit_free(TO_CIRCUIT(circ)); hs_free_all(); UNMOCK(circuit_mark_for_close_); } @@ -793,6 +796,7 @@ test_introduce2(void *arg) dummy_state = tor_malloc_zero(sizeof(or_state_t)); circ = helper_create_origin_circuit(CIRCUIT_PURPOSE_S_INTRO, flags); + tt_assert(circ); /* Test a wrong purpose. */ TO_CIRCUIT(circ)->purpose = CIRCUIT_PURPOSE_S_ESTABLISH_INTRO; @@ -844,7 +848,8 @@ test_introduce2(void *arg) done: or_state_free(dummy_state); dummy_state = NULL; - circuit_free(TO_CIRCUIT(circ)); + if (circ) + circuit_free(TO_CIRCUIT(circ)); hs_free_all(); UNMOCK(circuit_mark_for_close_); } |