summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/or/rephist.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index fe32ab1580..2cb2383935 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,9 @@ Changes in version 0.2.2.7-alpha - 2009-??-??
0.1.0.1-rc.
- Update our OpenSSL 0.9.8l fix so that it works with OpenSSL 0.9.8m
too.
+ - Do not segfault when writing buffer stats when we haven't observed
+ a single circuit to report about. Found by Fabian Lanze. Bugfix on
+ 0.2.2.1-alpha.
Changes in version 0.2.2.6-alpha - 2009-11-19
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 78ceb5f0d7..36318c7558 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2705,9 +2705,16 @@ rep_hist_buffer_stats_write(time_t now)
memset(circs_in_share, 0, SHARES * sizeof(int));
memset(queued_cells, 0, SHARES * sizeof(double));
memset(time_in_queue, 0, SHARES * sizeof(double));
+ if (!circuits_for_buffer_stats)
+ circuits_for_buffer_stats = smartlist_create();
smartlist_sort(circuits_for_buffer_stats,
_buffer_stats_compare_entries);
number_of_circuits = smartlist_len(circuits_for_buffer_stats);
+ if (number_of_circuits < 1) {
+ log_info(LD_HIST, "Attempt to write cell statistics to disk failed. "
+ "We haven't seen a single circuit to report about.");
+ goto done;
+ }
i = 0;
SMARTLIST_FOREACH_BEGIN(circuits_for_buffer_stats,
circ_buffer_stats_t *, stat)