mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-23 18:14:09 +08:00
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:
parent
f29e69ecc8
commit
46495be94d
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user