route: Fix memory leak on option or freed route

In this case there is no interface to compare the metric for.
As such, compare on pointer so we can maintain a free list.
This commit is contained in:
Roy Marples 2019-03-03 23:21:33 +00:00
parent f29e69ecc8
commit 46495be94d

View File

@ -71,7 +71,10 @@ rt_compare(__unused void *context, const void *node1, const void *node2)
return c;
/* Finally by interface metric. */
if (rt1->rt_ifp != NULL && rt2->rt_ifp != NULL)
if (rt1->rt_ifp == NULL || rt2->rt_ifp == NULL)
/* option or freed route */
c = rt1 == rt2 ? 0 : rt1 < rt2 ? -1 : 1;
else
c = (int)(rt1->rt_ifp->metric - rt2->rt_ifp->metric);
return c;