Add yang_stmt NULL check in yang_order to prevent SEGFAULT

This commit is contained in:
Vladimir Ratnikov 2019-04-25 06:20:15 -04:00
parent 16de5f47ba
commit 2f997b169a

View file

@ -850,6 +850,10 @@ yang_order(yang_stmt *y)
* if so, the real parent (from an xml point of view) is the parents * if so, the real parent (from an xml point of view) is the parents
* parent. * parent.
*/ */
if (y == NULL){
return -1;
}
yp = y->ys_parent; yp = y->ys_parent;
while (yp->ys_keyword == Y_CASE || yp->ys_keyword == Y_CHOICE) while (yp->ys_keyword == Y_CASE || yp->ys_keyword == Y_CHOICE)
yp = yp->ys_parent; yp = yp->ys_parent;