Skip to content

Commit

Permalink
out_oracle_log_analytics: fix mk_list cleanup function
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 committed Sep 24, 2023
1 parent eb127a3 commit ba44efd
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions plugins/out_oracle_log_analytics/oci_logan_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
flb_errno();
return NULL;
}
mk_list_init(&ctx->global_metadata_fields);
mk_list_init(&ctx->log_event_metadata_fields);

ctx->ins = ins;

Expand All @@ -298,8 +300,8 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
return NULL;
}
}

if (ctx->oci_la_global_metadata != NULL) {
mk_list_init(&ctx->global_metadata_fields);
ret = global_metadata_fields_create(ctx);
if (ret != 0) {
flb_errno();
Expand All @@ -309,7 +311,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
}

if (ctx->oci_la_metadata != NULL) {
mk_list_init(&ctx->log_event_metadata_fields);
ret = log_event_metadata_create(ctx);
if (ret != 0) {
flb_errno();
Expand Down Expand Up @@ -435,16 +436,24 @@ static void metadata_fields_destroy(struct flb_oci_logan *ctx)

mk_list_foreach_safe(head, tmp, &ctx->global_metadata_fields) {
f = mk_list_entry(head, struct metadata_obj, _head);
flb_sds_destroy(f->key);
flb_sds_destroy(f->val);
if (f->key) {
flb_sds_destroy(f->key);
}
if (f->val) {
flb_sds_destroy(f->val);
}
mk_list_del(&f->_head);
flb_free(f);
}

mk_list_foreach_safe(head, tmp, &ctx->log_event_metadata_fields) {
f = mk_list_entry(head, struct metadata_obj, _head);
flb_sds_destroy(f->key);
flb_sds_destroy(f->val);
if (f->key) {
flb_sds_destroy(f->key);
}
if (f->val) {
flb_sds_destroy(f->val);
}
mk_list_del(&f->_head);
flb_free(f);
}
Expand Down

0 comments on commit ba44efd

Please sign in to comment.