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:
Stephen Hemminger 2008-02-11 21:12:49 -08:00 committed by David S. Miller
parent e4f8b5d4ed
commit ec28cf738d
1 changed files with 2 additions and 4 deletions

View File

@ -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;
}