From f2428a284b61029a59ccf4d41c89db1070594722 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 9 Feb 2014 13:29:26 -0500 Subject: [PATCH] bufferevent_pair: don't call downcast(NULL) --- bufferevent_pair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bufferevent_pair.c b/bufferevent_pair.c index 6ec5cac8..e9ed9f59 100644 --- a/bufferevent_pair.c +++ b/bufferevent_pair.c @@ -310,13 +310,14 @@ struct bufferevent * bufferevent_pair_get_partner(struct bufferevent *bev) { struct bufferevent_pair *bev_p; - struct bufferevent *partner; + struct bufferevent *partner = NULL; bev_p = upcast(bev); if (! bev_p) return NULL; incref_and_lock(bev); - partner = downcast(bev_p->partner); + if (bev_p->partner) + partner = downcast(bev_p->partner); decref_and_unlock(bev); return partner; }