]> granicus.if.org Git - libevent/commitdiff
Do not crash when evhttp_send_reply_start() is called after a timeout.
authorAndreas Gustafsson <gson@gson.org>
Tue, 26 Sep 2017 16:23:29 +0000 (19:23 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sat, 2 Feb 2019 12:13:54 +0000 (15:13 +0300)
This fixes the crash reported in issue #509.  The "would be nice"
items discussed in #509 can be addressed separately.

(cherry picked from commit 99d0a952dada771b91acf63f5208b994e80a2986)

http.c

diff --git a/http.c b/http.c
index 8aa2b120c141f199aaebb23fd894a4557f1f0f28..d6dfeea14d8e46ed0e7211d088be64b58df1172e 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2822,6 +2822,10 @@ evhttp_send_reply_start(struct evhttp_request *req, int code,
     const char *reason)
 {
        evhttp_response_code_(req, code, reason);
+
+       if (req->evcon == NULL)
+               return;
+
        if (evhttp_find_header(req->output_headers, "Content-Length") == NULL &&
            REQ_VERSION_ATLEAST(req, 1, 1) &&
            evhttp_response_needs_body(req)) {