]> granicus.if.org Git - libevent/commitdiff
bufferevent_pair: don't call downcast(NULL)
authorNick Mathewson <nickm@torproject.org>
Sun, 9 Feb 2014 18:29:26 +0000 (13:29 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 9 Feb 2014 18:29:26 +0000 (13:29 -0500)
bufferevent_pair.c

index 6ec5cac81567587371dca862bd960d03114dd638..e9ed9f590720a0543c5cd0dc3ae79a5dbb464726 100644 (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;
 }