Skip to content

Commit 5ff0f12

Browse files
committed
parser: always destroy or link config format context
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 37ff210 commit 5ff0f12

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/flb_parser.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ int flb_parser_conf_file(const char *file, struct flb_config *config)
830830
char tmp[PATH_MAX + 1];
831831
char *cfg = NULL;
832832
struct stat st;
833-
struct flb_cf *cf;
833+
struct flb_cf *cf = NULL;
834834

835835
#ifndef FLB_HAVE_STATIC_CONF
836836
ret = stat(file, &st);
@@ -850,15 +850,9 @@ int flb_parser_conf_file(const char *file, struct flb_config *config)
850850
cfg = (char *) file;
851851
}
852852

853-
cf = flb_cf_create_from_file(config->cf_parsers, cfg);
853+
cf = flb_cf_create_from_file(NULL, cfg);
854854
#else
855855
cf = flb_config_static_open(file);
856-
if (cf) {
857-
if (config->cf_parsers) {
858-
flb_cf_destroy(config->cf_parsers);
859-
}
860-
config->cf_parsers = cf;
861-
}
862856
#endif
863857

864858
if (!cf) {
@@ -868,15 +862,19 @@ int flb_parser_conf_file(const char *file, struct flb_config *config)
868862
/* process 'parser' sections */
869863
ret = parser_conf_file(cfg, cf, config);
870864
if (ret == -1) {
865+
flb_cf_destroy(cf);
871866
return -1;
872867
}
873868

874869
/* processs 'multiline_parser' sections */
875870
ret = multiline_parser_conf_file(cfg, cf, config);
876871
if (ret == -1) {
872+
flb_cf_destroy(cf);
877873
return -1;
878874
}
879875

876+
/* link the 'cf parser' context to the config list */
877+
mk_list_add(&cf->_head, &config->cf_parsers_list);
880878
return 0;
881879
}
882880

0 commit comments

Comments
 (0)