diff --git a/src/config_format/flb_cf_yaml.c b/src/config_format/flb_cf_yaml.c index 2a571e59ea9..289760ec7c0 100644 --- a/src/config_format/flb_cf_yaml.c +++ b/src/config_format/flb_cf_yaml.c @@ -2041,7 +2041,12 @@ static int read_config(struct flb_cf *conf, struct local_ctx *ctx, yaml_parser_delete(&parser); /* free all remaining states */ - while (state = state_pop(ctx)); + if (code == -1) { + while (state = state_pop(ctx)); + } + else { + state = state_pop(ctx); + } fclose(fh); ctx->level--;