summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitlist.c5
-rw-r--r--src/or/connection.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 2a03f8a0d9..9d7a5d7f0e 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -885,6 +885,11 @@ circuit_free(circuit_t *circ)
cpath_ref_decref(ocirc->build_state->service_pending_final_cpath_ref);
}
tor_free(ocirc->build_state);
+
+ /* Cancel before freeing, if we haven't already succeeded or failed. */
+ if (ocirc->guard_state) {
+ entry_guard_cancel(get_guard_selection_info(), &ocirc->guard_state);
+ }
circuit_guard_state_free(ocirc->guard_state);
circuit_clear_cpath(ocirc);
diff --git a/src/or/connection.c b/src/or/connection.c
index c2a7a87d41..25c75ff101 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -634,6 +634,10 @@ connection_free_(connection_t *conn)
cached_dir_decref(dir_conn->cached_dir);
rend_data_free(dir_conn->rend_data);
+ if (dir_conn->guard_state) {
+ /* Cancel before freeing, if it's still there. */
+ entry_guard_cancel(get_guard_selection_info(), &dir_conn->guard_state);
+ }
circuit_guard_state_free(dir_conn->guard_state);
}