aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-18 21:17:40 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-18 21:17:40 -0400
commit1b3bddd013dab6d0aa8159e1690d944e226ed77f (patch)
treecb90a2f7824a0d5ca0ad19afb74bfd0f3d77b351 /src/or
parent78bc814c049fe67d0b521a288d3516248e110301 (diff)
downloadtor-1b3bddd013dab6d0aa8159e1690d944e226ed77f.tar
tor-1b3bddd013dab6d0aa8159e1690d944e226ed77f.tar.gz
scan-build: Have clear_pending_onions walk the lists more obviously
As it stands, it relies on the fact that onion_queue_entry_remove will magically remove each onionskin from the right list. This patch changes the logic to be more resilient to possible bugs in onion_queue_entry_remove, and less confusing to static analysis tools.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/onion.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/onion.c b/src/or/onion.c
index 30b983d91..72571b7bd 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -329,12 +329,14 @@ onion_queue_entry_remove(onion_queue_t *victim)
void
clear_pending_onions(void)
{
- onion_queue_t *victim;
+ onion_queue_t *victim, *next;
int i;
for (i=0; i<=MAX_ONION_HANDSHAKE_TYPE; i++) {
- while ((victim = TOR_TAILQ_FIRST(&ol_list[i]))) {
+ for (victim = TOR_TAILQ_FIRST(&ol_list[i]); victim; victim = next) {
+ next = TOR_TAILQ_NEXT(victim,next);
onion_queue_entry_remove(victim);
}
+ tor_assert(TOR_TAILQ_EMPTY(&ol_list[i]));
}
memset(ol_entries, 0, sizeof(ol_entries));
}