From 286e6f887128a8f9bb3addfb587d2e5b89ef892c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 22 Aug 2024 13:53:47 -0400 Subject: [PATCH] lib: Ensure SA that root cannot be NULL Signed-off-by: Donald Sharp --- lib/yang.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/yang.c b/lib/yang.c index 6a8e5223a09c..6c1aed00cc7b 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -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);