lib: Ensure SA that root cannot be NULL

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-08-22 13:53:47 -04:00
parent 4344ac1d28
commit 286e6f8871

View File

@ -1398,8 +1398,10 @@ LY_ERR yang_lyd_trim_xpath(struct lyd_node **root, const char *xpath)
}
}
darr_foreach_i (remove, i) {
if (remove[i] == *root)
if (remove[i] == *root) {
assert(*root);
*root = (*root)->next;
}
lyd_free_tree(remove[i]);
}
darr_free(remove);