Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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;
}