Skip to content

Commit

Permalink
config_format: yaml: throw an error when the array cannot be allocated.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan authored and edsiper committed Oct 17, 2023
1 parent b2072a4 commit 0d6d781
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/config_format/flb_cf_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0d6d781

Please sign in to comment.