From ab398d8ff9d656c6ea81892de39867a7c6c8774c Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 21 Mar 2022 08:21:19 +0100 Subject: [PATCH] BUG/MINOR: http-rules: Don't free new rule on allocation failure If allocation of a new HTTP rule fails, we must not release it calling free_act_rule(). The regression was introduced by the commit dd7e6c6dc ("BUG/MINOR: http-rules: completely free incorrect TCP rules on error"). This patch must only be backported if the commit above is backported. It should fix the issues #1627, #1628 and #1629. --- src/http_rules.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/http_rules.c b/src/http_rules.c index 9314d5aa7..d3f41bf14 100644 --- a/src/http_rules.c +++ b/src/http_rules.c @@ -99,7 +99,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li rule = new_act_rule(ACT_F_HTTP_REQ, file, linenum); if (!rule) { ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); - goto out_err; + goto out; } if (((custom = action_http_req_custom(args[0])) != NULL)) { @@ -164,6 +164,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li return rule; out_err: free_act_rule(rule); + out: return NULL; } @@ -177,7 +178,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li rule = new_act_rule(ACT_F_HTTP_RES, file, linenum); if (!rule) { ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); - goto out_err; + goto out; } if (((custom = action_http_res_custom(args[0])) != NULL)) { @@ -242,6 +243,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li return rule; out_err: free_act_rule(rule); + out: return NULL; } @@ -256,7 +258,7 @@ struct act_rule *parse_http_after_res_cond(const char **args, const char *file, rule = new_act_rule(ACT_F_HTTP_RES, file, linenum); if (!rule) { ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); - goto out_err; + goto out; } if (((custom = action_http_after_res_custom(args[0])) != NULL)) { @@ -311,6 +313,7 @@ struct act_rule *parse_http_after_res_cond(const char **args, const char *file, return rule; out_err: free_act_rule(rule); + out: return NULL; }