mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-19 10:14:41 +00:00
BUG/MINOR: log: fix potential lf->name memory leak
Recent commit2ed6068
("MINOR: log: custom name for logformat node") introduced a potential memory leak because when custom name is provided, lf->name value is allocated using strdup(), thus is expected to be freed alongside the node when the node is released. However lf->name was only freed in some common places within log.c cleanups and helpers func, but in reality there are still cases where lf nodes are manually freed without making use of freeing helpers. So this is what this patch does, it makes sure all lf freeing places now leverage the free_logformat_node() helper function that takes care of freeing all known allocated elements within the node, including custom name. This commit depends on: - "MINOR: log: add free_logformat_node() helper function" No backport needed unless2ed6068
gets backported.
This commit is contained in:
parent
1c2e16ba8a
commit
2462e5bcca
@ -3156,8 +3156,7 @@ init_proxies_list_stage1:
|
||||
* fall back to static rule
|
||||
*/
|
||||
LIST_DELETE(&node->list);
|
||||
free(node->arg);
|
||||
free(node);
|
||||
free_logformat_node(node);
|
||||
}
|
||||
|
||||
rule->dynamic = 0;
|
||||
@ -3227,8 +3226,7 @@ init_proxies_list_stage1:
|
||||
* fall back to static rule
|
||||
*/
|
||||
LIST_DELETE(&node->list);
|
||||
free(node->arg);
|
||||
free(node);
|
||||
free_logformat_node(node);
|
||||
}
|
||||
|
||||
srule->dynamic = 0;
|
||||
|
15
src/log.c
15
src/log.c
@ -332,8 +332,7 @@ int parse_logformat_var(char *arg, int arg_len, char *name, int name_len, int ty
|
||||
}
|
||||
if (node->type == LOG_FMT_GLOBAL) {
|
||||
*defoptions = node->options;
|
||||
free(node->arg);
|
||||
free(node);
|
||||
free_logformat_node(node);
|
||||
} else {
|
||||
if (logformat_keywords[j].config_callback &&
|
||||
logformat_keywords[j].config_callback(node, curproxy) != 0) {
|
||||
@ -357,11 +356,7 @@ int parse_logformat_var(char *arg, int arg_len, char *name, int name_len, int ty
|
||||
var[var_len] = j;
|
||||
|
||||
error_free:
|
||||
if (node) {
|
||||
free(node->arg);
|
||||
free(node->name);
|
||||
free(node);
|
||||
}
|
||||
free_logformat_node(node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -480,11 +475,7 @@ int add_sample_to_logformat_list(char *text, char *name, int name_len, int typec
|
||||
return 1;
|
||||
|
||||
error_free:
|
||||
release_sample_expr(expr);
|
||||
if (node) {
|
||||
free(node->arg);
|
||||
free(node);
|
||||
}
|
||||
free_logformat_node(node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user