From bdbc0db09582eac2d1c71eca1088e0ef598d6ef2 Mon Sep 17 00:00:00 2001 From: Harris Kaufmann Date: Wed, 15 Jul 2020 16:26:13 +0200 Subject: [PATCH] BUG/MEDIUM: fcgi-app: fix memory leak in fcgi_flt_http_headers When the loop is continued early, the memory for param_rule is not freed. This can leak memory per request, which will eventually consume all available memory on the server. This patch should fix the issue #750. It must be backported as far as 2.1. (cherry picked from commit b605a736b0766030746b50c322879d929fcebacf) Signed-off-by: Willy Tarreau (cherry picked from commit 4f472bedc8c696f9c18da0eb16904a98a37f076c) Signed-off-by: Christopher Faulet --- src/fcgi-app.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fcgi-app.c b/src/fcgi-app.c index b6bd6bb..2f54129 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -448,8 +448,10 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct b_reset(value); value->data = build_logline(s, value->area, value->size, param_rule->value); - if (!value->data) + if (!value->data) { + pool_free(pool_head_fcgi_param_rule, param_rule); continue; + } if (!http_add_header(htx, param_rule->name, ist2(value->area, value->data))) goto rewrite_err; pool_free(pool_head_fcgi_param_rule, param_rule); -- 1.7.10.4