diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 9534eaeb2..9204410aa 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -66,6 +66,7 @@ void deinit_log_buffers(void); /* Deinitialize log buffers used for syslog messages */ void free_logformat_list(struct list *fmt); +void free_logformat_node(struct logformat_node *node); /* build a log line for the session and an optional stream */ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format); diff --git a/src/log.c b/src/log.c index b0d022164..490a17e32 100644 --- a/src/log.c +++ b/src/log.c @@ -2660,6 +2660,19 @@ void deinit_log_forward() } } +/* Releases memory for a single log-format node */ +void free_logformat_node(struct logformat_node *node) +{ + if (!node) + return; + + release_sample_expr(node->expr); + node->expr = NULL; + ha_free(&node->name); + ha_free(&node->arg); + ha_free(&node); +} + /* Releases memory allocated for a log-format string */ void free_logformat_list(struct list *fmt) { @@ -2670,10 +2683,7 @@ void free_logformat_list(struct list *fmt) list_for_each_entry_safe(lf, lfb, fmt, list) { LIST_DELETE(&lf->list); - release_sample_expr(lf->expr); - free(lf->name); - free(lf->arg); - free(lf); + free_logformat_node(lf); } }