]> granicus.if.org Git - libevent/commitdiff
Fix an unlikely but possible error case for http connections
authorNick Mathewson <nickm@torproject.org>
Tue, 6 Aug 2013 23:17:08 +0000 (19:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 6 Aug 2013 23:17:08 +0000 (19:17 -0400)
Found by coverity

http.c

diff --git a/http.c b/http.c
index 55190e262abb5823379969b941ca81b9924df9e7..7b5326c970c3e878053c5f04e11314e4b37abfd4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1419,6 +1419,12 @@ evhttp_connection_cb(struct bufferevent *bufev, short what, void *arg)
                return;
        }
 
+       if (evcon->fd == -1) {
+               event_debug(("%s: bufferevent_getfd returned -1",
+                       __func__));
+               goto cleanup;
+       }
+
        /* Check if the connection completed */
        if (getsockopt(evcon->fd, SOL_SOCKET, SO_ERROR, (void*)&error,
                       &errsz) == -1) {