Because we try and free the ARP state when dhcpcd forks or an
interface is removed, the loop to work out the next state to free
could return invalid memory.
So test we have an ARP state each time we iterate and free.
struct iarp_state *state;
struct arp_state *astate;
- state = ARP_STATE(ifp);
- if (state == NULL)
- return;
-
- while ((astate = TAILQ_FIRST(&state->arp_states)) != NULL) {
+ while ((state = ARP_STATE(ifp)) != NULL &&
+ (astate = TAILQ_FIRST(&state->arp_states)) != NULL)
arp_free(astate);
- }
/* No need to close because the last free will close */
}