From 0d6d781d3d592a6cb4b8174aaac1f1427d9aa376 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 26 Sep 2023 10:40:32 -0300 Subject: [PATCH] config_format: yaml: throw an error when the array cannot be allocated. Signed-off-by: Phillip Whelan --- src/config_format/flb_cf_yaml.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config_format/flb_cf_yaml.c b/src/config_format/flb_cf_yaml.c index 289760ec7c0..70a41bd5e0d 100644 --- a/src/config_format/flb_cf_yaml.c +++ b/src/config_format/flb_cf_yaml.c @@ -648,11 +648,12 @@ static enum status state_copy_into_config_group(struct parser_state *state, stru case CFL_VARIANT_ARRAY: carr = cfl_array_create(kvp->val->data.as_array->entry_count); - if (carr) { + if (carr == NULL) { flb_error("unable to allocate array"); cfl_kvlist_destroy(copy); return YAML_FAILURE; } + for (idx = 0; idx < kvp->val->data.as_array->entry_count; idx++) { var = cfl_array_fetch_by_index(kvp->val->data.as_array, idx);