Skip to content

Commit

Permalink
Merge pull request FRRouting#14767 from idryzhov/fix-change-value-free
Browse files Browse the repository at this point in the history
lib: fix possible freeing of libyang data
  • Loading branch information
ton31337 authored Nov 12, 2023
2 parents e4ccc8f + 814b9fb commit 2c0c2c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ void nb_candidate_edit_config_changes(
struct nb_cfg_change *change = &cfg_changes[i];
struct nb_node *nb_node;
char xpath[XPATH_MAXLEN];
const char *value;
struct yang_data *data;
int ret;

Expand Down Expand Up @@ -814,9 +815,10 @@ void nb_candidate_edit_config_changes(
}

/* If the value is not set, get the default if it exists. */
if (change->value == NULL)
change->value = yang_snode_get_default(nb_node->snode);
data = yang_data_new(xpath, change->value);
value = change->value;
if (value == NULL)
value = yang_snode_get_default(nb_node->snode);
data = yang_data_new(xpath, value);

/*
* Ignore "not found" errors when editing the candidate
Expand Down

0 comments on commit 2c0c2c7

Please sign in to comment.