]> granicus.if.org Git - libevent/commitdiff
make evhttp_send() safe against terminated connections, too
authorNiels Provos <provos@gmail.com>
Thu, 4 Feb 2010 00:54:18 +0000 (16:54 -0800)
committerNiels Provos <provos@gmail.com>
Thu, 4 Feb 2010 00:54:18 +0000 (16:54 -0800)
http.c
include/event2/http.h

diff --git a/http.c b/http.c
index a9a144651cd71f7e2eec110a3d0c2d3ec912062b..e5b1a6fbbd5bf1d0c55ace4c7c78700453912e12 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2065,6 +2065,11 @@ evhttp_send(struct evhttp_request *req, struct evbuffer *databuf)
 {
        struct evhttp_connection *evcon = req->evcon;
 
+       if (evcon == NULL) {
+               evhttp_request_free(req);
+               return;
+       }
+
        EVUTIL_ASSERT(TAILQ_FIRST(&evcon->requests) == req);
 
        /* we expect no more calls form the user on this request */
index a56526e89110910722779592344872ad0300dbab..2c5ebf4cdefdc24c77be83624ed862b0bbf8324f 100644 (file)
@@ -374,7 +374,12 @@ void evhttp_request_own(struct evhttp_request *req);
 /** Returns 1 if the request is owned by the user */
 int evhttp_request_is_owned(struct evhttp_request *req);
 
-/** Returns the connection object associated with the request or NULL */
+/**
+ * Returns the connection object associated with the request or NULL
+ *
+ * The server needs to either free the request explicitly or call
+ * evhttp_send_reply_end().
+ */
 struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req);
 
 void evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon,