]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: filters: free the error message of the filter-config parsers
authorAleksandar Lazic <al-haproxy@none.at>
Sat, 17 Oct 2026 19:40:58 +0000 (21:40 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 19 Oct 2026 19:53:20 +0000 (21:53 +0200)
flt_precheck_instance() passes a message to the ->parse() callback of
the filter classes, which may allocate it with memprintf() to report an
error. The message was reported with ha_alert() but never released, so
it leaked each time a "filter-config" instance failed to be parsed, for
instance with "filter-config trace id t1 bogus-option", as reported by
ASAN.

This only happens on configuration errors, which are fatal at boot, but
the instances of the proxies created at runtime are parsed the same way.
Let's release the message once reported, and also on success in case a
parser fills it without failing.

This was brought by commit b3075cf7f ("MEDIUM: filters: Parse and
finalize filter-config instances") in 3.5-dev9, so no backport is
needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/filters.c

index a76a146ff9410a921198ace7f8614090ced79b56..ab1184b3d30f3cf186a249e9cea38a0710d5edef 100644 (file)
@@ -2869,8 +2869,10 @@ static int flt_precheck_instance(struct proxy *proxy, struct filter_instance *in
                         proxy_type_str(proxy), proxy->id, inst->class->name,
                         inst->conf.file, inst->conf.line,
                         err && *err ? err : "unknown error");
+               free(err);
                return ERR_ALERT | ERR_FATAL;
        }
+       free(err);
        if (!inst->fconf->ops) {
                ha_alert("config: %s '%s' : filter class '%s' defined no callbacks for the instance from %s:%d.\n",
                         proxy_type_str(proxy), proxy->id, inst->class->name,