bufferevent_pair: don't call downcast(NULL)

This commit is contained in:
Nick Mathewson 2014-02-09 13:29:26 -05:00
parent dfe1e526f5
commit f2428a284b

View File

@ -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;
}