From 6e002201933fa7e6f2f23948a333774cc06926c4 Mon Sep 17 00:00:00 2001 From: ~hatteb-mitlyd Date: Tue, 11 Mar 2014 14:11:03 -0700 Subject: [PATCH 1/2] avoid responding to a dead http req --- v/http.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/v/http.c b/v/http.c index 3019005b51..2ec3b50d4c 100644 --- a/v/http.c +++ b/v/http.c @@ -142,7 +142,14 @@ _http_write_cb(uv_write_t* wri_u, c3_i sas_i) static void _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) { - _u2_write_t* ruq_u = (_u2_write_t*) malloc(sizeof(_u2_write_t)); + _u2_write_t* ruq_u; + + // don't respond to a dead connection + if ( uv_is_closing((uv_handle_t*) &(req_u->hon_u->wax_u)) ) { + return; + } + + ruq_u = (_u2_write_t*) malloc(sizeof(_u2_write_t)); ruq_u->buf_y = (c3_y*)buf_u.base; From cff116fa0cc31e5b8b09d88d3efe3da8c4a7d75d Mon Sep 17 00:00:00 2001 From: ~hatteb-mitlyd Date: Tue, 11 Mar 2014 14:20:27 -0700 Subject: [PATCH 2/2] don't leak --- v/http.c | 1 + 1 file changed, 1 insertion(+) diff --git a/v/http.c b/v/http.c index 2ec3b50d4c..4dcd947182 100644 --- a/v/http.c +++ b/v/http.c @@ -146,6 +146,7 @@ _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u) // don't respond to a dead connection if ( uv_is_closing((uv_handle_t*) &(req_u->hon_u->wax_u)) ) { + free(buf_u.base); return; }