From ad7469ddc0d528319ea7e0d4d9952a7862dcdaf7 Mon Sep 17 00:00:00 2001 From: GabrielPaul <519784120@qq.com> Date: Fri, 17 Jan 2025 16:29:29 +0800 Subject: [PATCH] Fix #256 memory leak bug Update conf.c --- src/conf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 83b16206..892f8c95 100644 --- a/src/conf.c +++ b/src/conf.c @@ -659,12 +659,19 @@ static int zlog_conf_parse_line(zlog_conf_t * a_conf, char *line, int *section) /* now build rotater and default_format * from the unchanging global setting, * for zlog_rule_new() */ + if(a_conf->rotater){ + zlog_rotater_del(a_conf->rotater); + a_conf->rotater = NULL; + } a_conf->rotater = zlog_rotater_new(a_conf->rotate_lock_file); if (!a_conf->rotater) { zc_error("zlog_rotater_new fail"); return -1; } - + if(a_conf->default_format){ + zlog_format_del(a_conf->default_format); + a_conf->default_format = NULL; + } a_conf->default_format = zlog_format_new(a_conf->default_format_line, &(a_conf->time_cache_count)); if (!a_conf->default_format) {