summaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-28 10:37:22 -0400
committerNick Mathewson <nickm@torproject.org>2016-03-28 11:12:15 -0400
commitaddd18172167e549b28efc8cf1132e1b8f9d3972 (patch)
tree6b910ec4c71be4c4114a16a46249c861ee97c148 /src/or/circuitlist.c
parent65db5ae566d463dd682a2f63ddf448d04101dab6 (diff)
downloadtor-addd18172167e549b28efc8cf1132e1b8f9d3972.tar.gz
tor-addd18172167e549b28efc8cf1132e1b8f9d3972.zip
Fix memory leak in TestingEnableCellStatsEvent
Only when we were actually flushing the cell stats to a controller would we free them. Thus, they could stay in RAM even after the circuit was freed (eg if we didn't have any controllers). Fixes bug 18673; bugfix on 0.2.5.1-alpha.
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index d6532ddc5f..670c5b3c19 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -756,6 +756,18 @@ or_circuit_new(circid_t p_circ_id, channel_t *p_chan)
return circ;
}
+/** Free all storage held in circ->testing_cell_stats */
+void
+circuit_clear_testing_cell_stats(circuit_t *circ)
+{
+ if (!circ)
+ return;
+ SMARTLIST_FOREACH(circ->testing_cell_stats, testing_cell_stats_entry_t *,
+ ent, tor_free(ent));
+ smartlist_free(circ->testing_cell_stats);
+ circ->testing_cell_stats = NULL;
+}
+
/** Deallocate space associated with circ.
*/
STATIC void
@@ -767,6 +779,8 @@ circuit_free(circuit_t *circ)
if (!circ)
return;
+ circuit_clear_testing_cell_stats(circ);
+
if (CIRCUIT_IS_ORIGIN(circ)) {
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
mem = ocirc;