Skip to content

Commit 2f99a29

Browse files
committed
tree schema BUGFIX arg check in public functions
1 parent d4de9e6 commit 2f99a29

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/tree_schema_common.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,10 @@ lys_datatype2str(LY_DATA_TYPE basetype)
13801380
LIBYANG_API_DEF const struct lysp_tpdf *
13811381
lysp_node_typedefs(const struct lysp_node *node)
13821382
{
1383+
if (!node) {
1384+
return NULL;
1385+
}
1386+
13831387
switch (node->nodetype) {
13841388
case LYS_CONTAINER:
13851389
return ((struct lysp_node_container *)node)->typedefs;
@@ -1403,6 +1407,10 @@ lysp_node_typedefs(const struct lysp_node *node)
14031407
LIBYANG_API_DEF const struct lysp_node_grp *
14041408
lysp_node_groupings(const struct lysp_node *node)
14051409
{
1410+
if (!node) {
1411+
return NULL;
1412+
}
1413+
14061414
switch (node->nodetype) {
14071415
case LYS_CONTAINER:
14081416
return ((struct lysp_node_container *)node)->groupings;
@@ -1447,6 +1455,10 @@ lysp_node_actions(const struct lysp_node *node)
14471455
{
14481456
struct lysp_node_action **actions;
14491457

1458+
if (!node) {
1459+
return NULL;
1460+
}
1461+
14501462
actions = lysp_node_actions_p((struct lysp_node *)node);
14511463
if (actions) {
14521464
return *actions;
@@ -1478,6 +1490,10 @@ lysp_node_notifs(const struct lysp_node *node)
14781490
{
14791491
struct lysp_node_notif **notifs;
14801492

1493+
if (!node) {
1494+
return NULL;
1495+
}
1496+
14811497
notifs = lysp_node_notifs_p((struct lysp_node *)node);
14821498
if (notifs) {
14831499
return *notifs;
@@ -1621,6 +1637,7 @@ struct lysc_node_action **
16211637
lysc_node_actions_p(struct lysc_node *node)
16221638
{
16231639
assert(node);
1640+
16241641
switch (node->nodetype) {
16251642
case LYS_CONTAINER:
16261643
return &((struct lysc_node_container *)node)->actions;
@@ -1636,6 +1653,10 @@ lysc_node_actions(const struct lysc_node *node)
16361653
{
16371654
struct lysc_node_action **actions;
16381655

1656+
if (!node) {
1657+
return NULL;
1658+
}
1659+
16391660
actions = lysc_node_actions_p((struct lysc_node *)node);
16401661
if (actions) {
16411662
return *actions;
@@ -1648,6 +1669,7 @@ struct lysc_node_notif **
16481669
lysc_node_notifs_p(struct lysc_node *node)
16491670
{
16501671
assert(node);
1672+
16511673
switch (node->nodetype) {
16521674
case LYS_CONTAINER:
16531675
return &((struct lysc_node_container *)node)->notifs;
@@ -1663,6 +1685,10 @@ lysc_node_notifs(const struct lysc_node *node)
16631685
{
16641686
struct lysc_node_notif **notifs;
16651687

1688+
if (!node) {
1689+
return NULL;
1690+
}
1691+
16661692
notifs = lysc_node_notifs_p((struct lysc_node *)node);
16671693
if (notifs) {
16681694
return *notifs;
@@ -1750,6 +1776,10 @@ lysc_node_musts(const struct lysc_node *node)
17501776
{
17511777
struct lysc_must **must_p;
17521778

1779+
if (!node) {
1780+
return NULL;
1781+
}
1782+
17531783
must_p = lysc_node_musts_p(node);
17541784
if (must_p) {
17551785
return *must_p;
@@ -1796,6 +1826,10 @@ lysc_node_when(const struct lysc_node *node)
17961826
{
17971827
struct lysc_when ***when_p;
17981828

1829+
if (!node) {
1830+
return NULL;
1831+
}
1832+
17991833
when_p = lysc_node_when_p(node);
18001834
if (when_p) {
18011835
return *when_p;

0 commit comments

Comments
 (0)