BUG/MINOR: ssl/ckch: leak in error path

fdcb97614cb ("MINOR: ssl/ckch: add substring parser for ckch_conf")
introduced a leak in the error path when the strndup fails.

This patch fixes issue #2920. No backport needed.
This commit is contained in:
William Lallemand 2025-04-02 09:42:44 +02:00
parent 9fe72bba3c
commit 2e8acf54d4

View File

@ -4817,13 +4817,13 @@ int ckch_conf_parse(char **args, int cur_arg, struct ckch_conf *f, int *found, c
if (!r) { if (!r) {
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT; err_code |= ERR_ALERT | ERR_ABORT;
goto out; goto array_err;
} }
r[n] = strndup(b, e - b); r[n] = strndup(b, e - b);
if (!r[n]) { if (!r[n]) {
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT; err_code |= ERR_ALERT | ERR_ABORT;
goto out; goto array_err;
} }
n++; n++;
@ -4847,6 +4847,15 @@ int ckch_conf_parse(char **args, int cur_arg, struct ckch_conf *f, int *found, c
// while (*r) // while (*r)
// fprintf(stderr, "sub: \"%s\"\n", *r++); // fprintf(stderr, "sub: \"%s\"\n", *r++);
goto out;
array_err:
while (*r) {
char *prev = *r;
r++;
free(prev);
}
free(r);
} else if (ckch_conf_kws[i].type == PARSE_TYPE_INT) { } else if (ckch_conf_kws[i].type == PARSE_TYPE_INT) {
int *t = target; int *t = target;