]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: fix memory leaks on realloc failure in ssl_ckch.c
authorIlia Shipitsin <chipitsine@gmail.com>
Mon, 13 Apr 2026 16:14:50 +0000 (18:14 +0200)
committerWilliam Lallemand <wlallemand@irq6.net>
Sat, 25 Apr 2026 09:08:21 +0000 (11:08 +0200)
Replace bare realloc() calls with my_realloc2(), which frees the original
pointer on allocation failure, preventing a memory leak when the pointer
is subsequently overwritten with NULL.

Must be backported to 3.2.

src/ssl_ckch.c

index 122d314e6e12e250f813d197198a375ebfdc0fe6..75392a6c2cc895c5eb0058af89ca58879b224abd 100644 (file)
@@ -1098,7 +1098,7 @@ struct ckch_store *ckchs_dup(const struct ckch_store *src)
                /* copy the array of domain strings */
 
                while (src->conf.acme.domains[n]) {
-                       r = realloc(r, sizeof(char *) * (n + 2));
+                       r = my_realloc2(r, sizeof(char *) * (n + 2));
                        if (!r)
                                goto error;
 
@@ -5197,7 +5197,7 @@ int ckch_conf_parse(char **args, int cur_arg, struct ckch_conf *f, int *found, c
                                do {
                                        while (*e != ',' && *e != '\0')
                                                e++;
-                                       r = realloc(r, sizeof(char *) * (n + 2));
+                                       r = my_realloc2(r, sizeof(char *) * (n + 2));
                                        if (!r) {
                                                ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
                                                err_code |= ERR_ALERT | ERR_ABORT;