lib: Fix Null pointer derenference that happened to not crash

lib/yang.c:248:3: runtime error: member access within null pointer of type 'struct lysc_node_action'
lib/yang.c:254:3: runtime error: member access within null pointer of type 'struct lysc_node_notif'

If this data structure happens to ever be moved around we'll start
crashing.  Let's just fix it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-05-22 21:04:30 -04:00
parent b4c884b9ae
commit 2d0ddde65c

View file

@ -251,17 +251,25 @@ int yang_snodes_iterate(const struct lys_module *module, yang_iterate_cb cb,
if (ret == YANG_ITER_STOP)
return ret;
}
LY_LIST_FOR (&module_iter->compiled->rpcs->node, snode) {
ret = yang_snodes_iterate_subtree(snode, module, cb,
flags, arg);
if (ret == YANG_ITER_STOP)
return ret;
if (module_iter->compiled->rpcs) {
LY_LIST_FOR (&module_iter->compiled->rpcs->node, snode) {
ret = yang_snodes_iterate_subtree(snode, module,
cb, flags,
arg);
if (ret == YANG_ITER_STOP)
return ret;
}
}
LY_LIST_FOR (&module_iter->compiled->notifs->node, snode) {
ret = yang_snodes_iterate_subtree(snode, module, cb,
flags, arg);
if (ret == YANG_ITER_STOP)
return ret;
if (module_iter->compiled->notifs) {
LY_LIST_FOR (&module_iter->compiled->notifs->node,
snode) {
ret = yang_snodes_iterate_subtree(snode, module,
cb, flags,
arg);
if (ret == YANG_ITER_STOP)
return ret;
}
}
}