]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: memory leak with captures when using keep-alive
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Jan 2010 12:35:21 +0000 (13:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 7 Jan 2010 12:35:21 +0000 (13:35 +0100)
Hank A. Paulson reported a massive memory leak when using keep-alive
mode. The information he provided made it easy to find that captured
request and response headers were erased but not released when renewing
a request.

src/proto_http.c

index 12647df230e78dc9fe970af77f939cc59bcd7eb1..9b9176caeac65f8720da690467e51dde8c281eec 100644 (file)
@@ -6310,11 +6310,19 @@ void http_init_txn(struct session *s)
        if (fe->options2 & PR_O2_REQBUG_OK)
                txn->req.err_pos = -1;            /* let buggy requests pass */
 
-       if (txn->req.cap)
+       if (txn->req.cap) {
+               struct cap_hdr *h;
+               for (h = fe->req_cap; h; h = h->next)
+                       pool_free2(h->pool, txn->req.cap[h->index]);
                memset(txn->req.cap, 0, fe->nb_req_cap * sizeof(void *));
+       }
 
-       if (txn->rsp.cap)
+       if (txn->rsp.cap) {
+               struct cap_hdr *h;
+               for (h = fe->rsp_cap; h; h = h->next)
+                       pool_free2(h->pool, txn->rsp.cap[h->index]);
                memset(txn->rsp.cap, 0, fe->nb_rsp_cap * sizeof(void *));
+       }
 
        if (txn->hdr_idx.v)
                hdr_idx_init(&txn->hdr_idx);