]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: cache: fix memory leak in parse_cache_rule error path
authorWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 13:26:32 +0000 (15:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 May 2026 14:04:19 +0000 (16:04 +0200)
When the filter config (fconf) allocation fails in parse_cache_rule,
the previously allocated cache_flt_conf (cconf) and its strdup'd name
string are not freed. The error path only freed cconf but not
cconf->c.name, causing a memory leak.

No backport is needed.

src/cache.c

index 9bed02004ea5078d564dce504651d31ad8f136d6..4f4870524109b715fdc963289c59f78744caaccd 100644 (file)
@@ -1950,7 +1950,10 @@ static int parse_cache_rule(struct proxy *proxy, const char *name, struct act_ru
        return 1;
 
   err:
-       free(cconf);
+       if (cconf) {
+               free(cconf->c.name);
+               free(cconf);
+       }
        return 0;
 }