fib_trie: handle empty tree
This fixes possible problems when trie_firstleaf() returns NULL to trie_leafindex(). Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e4f8b5d4ed
commit
ec28cf738d
1 changed files with 2 additions and 4 deletions
|
@ -1762,11 +1762,9 @@ static struct leaf *trie_leafindex(struct trie *t, int index)
|
|||
{
|
||||
struct leaf *l = trie_firstleaf(t);
|
||||
|
||||
while (index-- > 0) {
|
||||
while (l && index-- > 0)
|
||||
l = trie_nextleaf(l);
|
||||
if (!l)
|
||||
break;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue