From: Christopher Faulet Date: Mon, 21 Mar 2022 07:21:19 +0000 (+0100) Subject: BUG/MINOR: http-rules: Don't free new rule on allocation failure X-Git-Tag: v2.6-dev4~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab398d8ff9d656c6ea81892de39867a7c6c8774c;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/http_rules.c b/src/http_rules.c index 9314d5aa71..d3f41bf14c 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; }