summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-09-14 14:27:41 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-09-15 11:40:59 -0400
commit3d2d8d6841a7ad7247278e837165e14d2ced43db (patch)
tree8563b4c31976b65ba1e00e14ccef7a811cf5613e
parent14cd8bdd4ba6f4c5946ecd9877c77c9ba305bbe8 (diff)
downloadtor-3d2d8d6841a7ad7247278e837165e14d2ced43db.tar.gz
tor-3d2d8d6841a7ad7247278e837165e14d2ced43db.zip
sched: Extra careful in channel_outbuf_length()
In case we don't have a connection object in the channel, just be careful and recover. Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/or/scheduler_kist.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index b4234a053b..2733e78f0d 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -116,6 +116,12 @@ static scheduler_t *kist_scheduler = NULL;
static inline size_t
channel_outbuf_length(channel_t *chan)
{
+ /* In theory, this can not happen because we can not scheduler a channel
+ * without a connection that has its outbuf initialized. Just in case, bug
+ * on this so we can understand a bit more why it happened. */
+ if (BUG(BASE_CHAN_TO_TLS(chan)->conn == NULL)) {
+ return 0;
+ }
return buf_datalen(TO_CONN(BASE_CHAN_TO_TLS(chan)->conn)->outbuf);
}