diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 0051cba625..d7aceb55b9 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -250,8 +250,7 @@ static void _nexthop_add_sorted(struct nexthop **head, { struct nexthop *position, *prev; - /* Ensure this gets set */ - nexthop->next = NULL; + assert(!nexthop->next); for (position = *head, prev = NULL; position; prev = position, position = position->next) { @@ -281,6 +280,8 @@ void nexthop_group_add_sorted(struct nexthop_group *nhg, { struct nexthop *tail; + assert(!nexthop->next); + /* Try to just append to the end first; * trust the list is already sorted */