Commit ec28cf73 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

fib_trie: handle empty tree

This fixes possible problems when trie_firstleaf() returns NULL
to trie_leafindex().
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e4f8b5d4
...@@ -1762,11 +1762,9 @@ static struct leaf *trie_leafindex(struct trie *t, int index) ...@@ -1762,11 +1762,9 @@ static struct leaf *trie_leafindex(struct trie *t, int index)
{ {
struct leaf *l = trie_firstleaf(t); struct leaf *l = trie_firstleaf(t);
while (index-- > 0) { while (l && index-- > 0)
l = trie_nextleaf(l); l = trie_nextleaf(l);
if (!l)
break;
}
return l; return l;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment